-
-
Notifications
You must be signed in to change notification settings - Fork 918
Implement the Relay Global Object Identification Specification #1585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Graphql/Type/SchemaBuilder.php
Outdated
$this->itemMutationResolverFactory = $itemMutationResolverFactory; | ||
$this->defaultFieldResolver = $defaultFieldResolver; | ||
$this->paginationEnabled = $paginationEnabled; | ||
} | ||
|
||
public function getSchema(): Schema | ||
{ | ||
$queryFields = []; | ||
$nodeInterface = $this->getNodeInterface(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not storing the type in $graphqlTypes
instead of passing it in all the methods?
src/Graphql/Type/SchemaBuilder.php
Outdated
], | ||
], | ||
'resolveType' => function ($value) { | ||
if (!isset($value['#item'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe #item
should be a const.
src/Graphql/Type/SchemaBuilder.php
Outdated
@@ -179,17 +226,20 @@ private function getResourceFieldConfiguration(string $fieldDescription = null, | |||
'resolve' => $resolve, | |||
]; | |||
} catch (InvalidTypeException $e) { | |||
return null; | |||
// return null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not deleting it?
} | ||
|
||
/** | ||
* Gets the fields of the type of the given resource. | ||
*/ | ||
private function getResourceObjectTypeFields(string $resource, bool $isInput = false, bool $isMutation = false, string $mutationName = null): array | ||
private function getResourceObjectTypeFields(string $resource, bool $input = false, string $mutationName = null): array | ||
{ | ||
$fields = []; | ||
$idField = ['type' => GraphQLType::id()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be wrapped by GraphQLType::nonNull() as it implements Relay Node interface now, and Node.id required to be nonNull. Commenting here as I'm not sure how much you have progressed after this commit, will submit PR if required. Thank you for all your work!
P.S. Line in question is 328, ['type' => GraphQLType::id()]
should be ['type' => GraphQLType::nonNull(GraphQLType::id())]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has not be fixed. Can I let you do the PR? Thanks for the review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dunglas saw you already did that, though it would be faster for you anyway, as you were still working in that file :) Thank you for all your work once again! Waiting for your blog entry on GraphQL :) have a good weekend 🎉
Implementation of the GraphQL's Relay Global Object Identification Specification using hypermedia IRIs.
You can now execute this kind of queries on the GraphQL endpoint:
Note: I'll probably extract the GraphQL type builder in a from the
SchemaBuilder
in a following PR.