profile
viewpoint

joaogarin/angular-electron 155

Angular2 and Electron starter using webpack

joaogarin/css-modules-angular2 22

Css modules working with Angular2

joaogarin/angularfire2-firebase3-electron 12

Firebase 3 with angularfire2 and Electron

drupal-graphql/graphql-search-api 7

GraphQL & Drupal Search API integration.

joaogarin/carte-blanche-angular2 6

Carte blanche implementation for angular2 WIP

joaogarin/Drupal-React-burger 5

A React component being rendered in Drupal

joaogarin/angularadmin 3

Angular Js admin theme

BioPhoton/angular-vienna-logo 2

Official angular vienna theme. Feel free to collaborate!

joaogarin/angular2-social-links 2

Angular2 social links component

duartegarin/graphql_search_api 1

Drupal graphql search api integration

pull request commentdrupal-graphql/graphql

Rewrite fromPath to use PropertyPath data producer

I couldn't quite understand what I had written above so for anyone else coming to this issue, just a recap of what's happening.

The path to our test failure

ResolverBuilderTest::testFromPath tests the ResolverBuilder::fromPath function that we change in this PR. It does this by creating a schema that includes a resolver using the fromPath resolver for the tree type.

When the request is resolved (executed) this calls the PropertyPath::resolve method with the values configured in the builder. In this the It's called with $path set to path.uri; $value set to the array returned for the tree field in our mockResolver for Query in ResolverBuilderTest::testFromPath; and finally $type set to tree.

In this case value is a plain array so it's not an instance of TypedDataInterface and thus PropertyPath::resolve tries to create a typed value. For this it calls TypedDataManagerInterface::createDataDefinition followed by TypedDataManagerInterface::create. The used implementation for TypedDataManagerInterface::createDataDefinition (in TypedDataManager) calls TypedDataManager::getDefinition.

This is where the current test implementation fails as it could not find a typed data definition for tree (the value of $type in our PropertyPath::resolve function that has been passed down all the way here).

Our test mocks two things:

  1. The TypedDataManagerInterface::create function to returns our mocked tree typed data so we don't have to define a typed data type but can just fake it.
  2. The TypedDataManagerInterface::getDefinition is mocked so that classes who want to know what definition we have for our fake data can still find t.

Why our test fails

The TypedDataManagerInterface::getDefinition wasn't actually ever called. The Path Resolver class bypassed this by calling DataDefinition::create($type) instead of the getDefinition method in case the type wasn't yet a valid data definition.

The PropertyPath data producer does call the getDefinition method (which is the better way to go, since it actually loads the data definition). However, it appears that our test doesn't provide a valid response here which causes TypedDataManager::createDataDefinition to throw a InvalidArgumentException.

This is firstly probably caused by https://github.com/drupal-graphql/graphql/commit/a5c599eb5c416960190d33daaa4076475abfa7ea which renames tree to tree_mock. Even though the type used elsewhere is still tree.

Changing this is not enough since the resulting return value is an array of ['class' => ComplexDataInterface::class]. So this gets us past the check for a return value for getDefinition. The TypedDataManager::createDataDefinition then uses the definition_class of the return value to instantiate the data definition instance with the data type it was previously passed. So we must also change the class property to definition_class. Finally, we can not instantiate an interface but must provide a concrete class. So we also switch to MapDataDefinition which seems to be closest to what we're trying to do.

We then run into additional problems because we're mocking too much of the TypedDataManager which causes the context definitions for the inputs to the PropertyPath DataProducer to fail altogether.

Eventually the easiest method seems to actually define some typed data and instantiate it as our fake datasource.

Kingdutch

comment created time in 5 hours

issue commentdrupal-graphql/graphql

[4.x] - Entity reference producer with a single value?

I was struggling to find the correct order and arguments for the chaining mentioned so my solution was to add a callback right after the entity_reference:

$builder->callback(function ($entity) {
  return $entity[0];
})

Add an empty array check for robustness.

kevineinarsson

comment created time in a day

issue commentdrupal-graphql/graphql

[4.x] - Entity reference producer with a single value?

I have a quite similar problem, my solution was to use property_path as well. If you use the path to the entity instead of the target_id, you do not need the entity_load. But it still looks like a workaround.

kevineinarsson

comment created time in a day

issue openeddrupal-graphql/graphql

[4.x] - Entity reference producer with a single value?

Hello!

I have a case where I have an entity with a reference to a media entity, which has a reference to an image entity which I would like to produce the URL for.

I expected to be able to get the referenced entity by just chaining entity_reference producers, something like this:

      $builder->compose(
        $builder->produce('entity_reference')
        ->map('entity', $builder->fromParent())
        ->map('field', $builder->fromValue('field_image')),
        $builder->produce('entity_reference')
        ->map('entity', $builder->fromParent())
        ->map('field', $builder->fromValue('field_media_image')),
        $builder->produce('image_url')
        ->map('entity', $builder->fromParent())
      )
    );

The problem I'm facing is that the first entity_reference producer always returns an array, even though I know in this case it's a singleton item, and that doesn't play nicely with the second entity_reference producer call. Could it be possible to map in a context value that tells the producer to only return the first item in the array? It would make use cases like this possible.

For now, I solved this by chaining property_path and entity_load for each reference but it feels like it's very verbose in comparison to the above example.

created time in a day

issue openeddrupal-graphql/graphql-search-api

Not equal to (<>) operator on condition does not allow for NULL value

I'm trying to query for any items in an index that do not have a null string field. I have found that because the value field is required for the ConditionInput I cannot accomplish this. I have tested making the value field in the ConditionInput optional and that does allow me to query for items where a given field is null.

Below is a working example after I modified the Drupal\graphql_search_api\Plugin\GraphQL\InputTypes\ConditionInput.php file

query{ searchAPISearch( index_id:"default_solr_index", conditions: [{ operator: "<>" name: "field_my_field" }]) { result_count documents { ... on DefaultSolrIndexDoc { nid title field_my_field } } } }

I edited the ConditionInput.php file to look like `<?php

namespace Drupal\graphql_search_api\Plugin\GraphQL\InputTypes;

use Drupal\graphql\Plugin\GraphQL\InputTypes\InputTypePluginBase;

/**

  • Condition input type.
  • @GraphQLInputType(
  • id = "condition_input",
  • name = "ConditionInput",
  • fields = {
  • "name" = "String!",
    
  • "value" = "String",
    
  • "operator" = "String"
    
  • }
  • ) */ class ConditionInput extends InputTypePluginBase {

} `

Is there a different way I can query for an item without a null field value, or is this a bug?

created time in 2 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

For those who come after:

I chose to solve this for my use-case by extending the EntityBuffer with my own class and injecting the access check there.

darvanen

comment created time in 3 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

Yeah the 4.x offers a lot of power and flexibility on top of the GraphQL library which is awesome. However, it also requires a bit of deeper understanding of GraphQL in PHP and quite a lot more plumbing :)

I hope the examples are able to help! If you want to follow along with how we're using the module you can take a look at the Draft PR in Open Social: github.com/goalgorilla/open_social/pull/1994/

darvanen

comment created time in 3 days

PR closed drupal-graphql/graphql

Make the EntityBuffer check access rights

Individual entity loads have access checks in place but if you load them via a QueryConnection wrapper they're skipped entirely. This is probably just a starting point, what have I missed?

+1 -1

4 comments

1 changed file

darvanen

pr closed time in 3 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

There's a lot to unpack in there, but it does help, thank you, and I can see this PR isn't going to go anywhere so I'll close it.

darvanen

comment created time in 3 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

Good question :D I'm assuming you mean https://github.com/drupal-graphql/graphql/blob/8.x-4.x/examples/graphql_example/src/Wrappers/QueryConnection.php Perhaps we should improve it 🤔

In Open Social I did something slightly differently. I load the entities before creating the connection. https://github.com/goalgorilla/open_social/blob/feature/graphql-base/modules/custom/social_graphql/src/Plugin/GraphQL/DataProducer/Entity/QueryEntityBase.php#L116

The connection doesn't receive entities directly but it receives edges: https://github.com/goalgorilla/open_social/blob/feature/graphql-base/modules/custom/social_graphql/src/Wrappers/EntityConnection.php

The edges receive a loaded entity instead of the query: https://github.com/goalgorilla/open_social/blob/feature/graphql-base/modules/custom/social_graphql/src/Wrappers/EntityEdge.php

The wrapping to edges is handled in the data producer that also handles the query: https://github.com/goalgorilla/open_social/blob/feature/graphql-base/modules/custom/social_graphql/src/Plugin/GraphQL/DataProducer/Entity/QueryEntityBase.php#L140

I hope that helps :D

darvanen

comment created time in 3 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

Fair points... how would you suggest doing EntityInterface::access() checks in the QueryConnection?

darvanen

comment created time in 3 days

pull request commentdrupal-graphql/graphql

Make the EntityBuffer check access rights

I’m not sure this is the right place to do this check. I may misunderstand but from a quick glance this causes a few issues:

  • no way to bypass the access check in case it’s already done
  • can’t change the operation the access check is being done for
  • can’t change the user the access check is being performed with
  • this potentially doesn’t help if non-user based access handling is performed (e.g. OAuth scopes with the anonymous user) although that’s implementation dependent I suppose

What’s the reason this isn’t/can’t be done in/before the QueryConnection?

darvanen

comment created time in 5 days

push eventdrupal-graphql/graphql

Klaus Purer

commit sha 3315f5d6637ad99838585eb9877b2b94eed3b725

test(phpstan): Enable PHPstan level 5 (#1123)

view details

push time in 5 days

pull request commentdrupal-graphql/graphql

Fix warning for non-variables passed by reference

While working on PHPStan level 5 it also detected this error, so will merge this without test since we will have coverage by PHPStan.

Kingdutch

comment created time in 5 days

push eventdrupal-graphql/graphql

Alexander Varwijk

commit sha 668b413df356be3e85370e7b37de3238bcae7bbd

fix(ui): Fix PHP warning for non-variables passed by reference (#1080) * Fix notice about variables passed by reference `reset` only takes variables so we can not pass the result of `array_keys` directly but have to use an intermediate variable. * Merge variable fallback expressions `array_key_exists('schema', $input) ? $input['schema'] : NULL` is equal to `$input['schema'] ?? NULL` on PHP versions that support the null-coalescing operator. Since we already use this elsewhere we already require such PHP versions. This allows us to substitute the simplified one-use variable leading to `$input['schema'] ?? NULL ?? $server->get('schema')`. The expression `?? NULL ??` can be safely transformed to `??` to result in the simplified expression in this commit. Co-authored-by: Klaus Purer <klaus.purer@protonmail.ch>

view details

push time in 5 days

PR merged drupal-graphql/graphql

Fix warning for non-variables passed by reference 4.x needs tests

#878 made some changes already but left a reset(array_keys()) call behind which on PHP 7.2 provides a notice when opening the ServerForm.

Notice: Only variables should be passed by reference in Drupal\graphql\Form\ServerForm->form() (line 95 of modules/contrib/graphql/src/Form/ServerForm.php).
Drupal\graphql\Form\ServerForm->form(Array, Object) (Line: 149)
[...]

The attached commit solves this by introducing a temporary variable. Based on feedback from PHPMD I've also simplified the expression and added a comment for people who may not be very familiar with the null-coalescing operator.

+4 -2

2 comments

1 changed file

Kingdutch

pr closed time in 5 days

fork manekinekko/the-dotnetbot-exhibition

A simple website to help your make your first Pull Request

fork in 5 days

issue commentdrupal-graphql/graphql

Implement automatic schema generators for all Drupal entities in GraphQL 4.x

Hm, I think I would not add that to the project page, since we don't want to encourage people to use a generated schema.

So I think I would leave the discussion just in this issue for now.

MurzNN

comment created time in 6 days

issue commentdrupal-graphql/graphql

Implement automatic schema generators for all Drupal entities in GraphQL 4.x

@klausi How about to add link to this discussion to that paragraph on the project page? It took long time for me to find this statements. :-)

Btw, I think it yould be also good to write your statement about schema-generating submodule in 4.x to that paragraph, because it is better to hire potential community work for this than for maintainance of 3.x.

MurzNN

comment created time in 6 days

push eventdrupal-graphql/graphql

Klaus Purer

commit sha b235e07fd6594dd27cad9a97f9b1808be7ad30e9

fix(files): Fix lock release handling when the file upload does not validate (#1118)

view details

push time in 7 days

PR merged drupal-graphql/graphql

fix(files): Fix lock release handling when the file upload does not validate 4.x

Follow-up to #1115 . We need to release the lock correctly when file validation fails.

I found the finally keyword in PHP which does exactly what we want, yay! https://www.php.net/manual/en/language.exceptions.php

Did not open a Drupal core issue yet, same bug in FileUploadResource.

+79 -36

0 comment

2 changed files

klausi

pr closed time in 7 days

PR opened drupal-graphql/graphql

Add image ID to ImageDerivative

Resolves #1120

+1 -0

0 comment

1 changed file

pr created time in 7 days

issue openeddrupal-graphql/graphql

Composing data producer example is broken

The code snippet that shows how $builder->compose can be used to load the currentUser is broken. The current_user data producer produces an AccountInterface instance, but the entity_load id field requires a string or an int.

The current incorrect snippet is the following part.

$builder->compose(
  $builder->produce('current_user'),
  $builder->produce('entity_load')
    ->map('type', $builder->fromValue('user'))
    ->map('id', $builder->fromParent())
);

For a query

query {
  currentUser { uuid }
}

It causes the following output

{
  "data": {
    "currentUser": null
  },
  "extensions": [
    {
      "message": "Object of class Drupal\\Core\\Session\\UserSession could not be converted to string",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "currentUser"
      ]
    }
  ]
}

created time in 7 days

issue openeddrupal-graphql/graphql

Add image ID to image derivative

ImageDerivative only returns image url, width, and height. https://github.com/drupal-graphql/graphql/blob/582704b321379323efba68ece4b7a07257e07f65/src/Plugin/GraphQL/DataProducer/Entity/Fields/Image/ImageDerivative.php#L132-L136

I would like to be able to access the entity's ID as well.

created time in 7 days

PublicEvent

PR opened drupal-graphql/graphql

Make the EntityBuffer check access rights

Individual entity loads have access checks in place but if you load them via a QueryConnection wrapper they're skipped entirely. This is probably just a starting point, what have I missed?

+1 -1

0 comment

1 changed file

pr created time in 7 days

starteddatastacktv/data-engineer-roadmap

started time in 7 days

startedclimate-strike/license

started time in 7 days

more