Skip to content

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

Merged
merged 2 commits into from
Dec 21, 2017

Conversation

dunglas
Copy link
Member

@dunglas dunglas commented Dec 21, 2017

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets n/a
License MIT
Doc PR todo

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:

    {
      node(id: "/product/ABC") {
        id
        ... on Product {
          name
        }
      }
    }

Note: I'll probably extract the GraphQL type builder in a from the SchemaBuilder in a following PR.

$this->itemMutationResolverFactory = $itemMutationResolverFactory;
$this->defaultFieldResolver = $defaultFieldResolver;
$this->paginationEnabled = $paginationEnabled;
}

public function getSchema(): Schema
{
$queryFields = [];
$nodeInterface = $this->getNodeInterface();
Copy link
Member

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?

],
],
'resolveType' => function ($value) {
if (!isset($value['#item'])) {
Copy link
Member

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.

@@ -179,17 +226,20 @@ private function getResourceFieldConfiguration(string $fieldDescription = null,
'resolve' => $resolve,
];
} catch (InvalidTypeException $e) {
return null;
// return null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not deleting it?

@dunglas dunglas merged commit 7113a05 into api-platform:master Dec 21, 2017
}

/**
* 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()];
Copy link

@dkozickis dkozickis Dec 22, 2017

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())]

Copy link
Member Author

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!

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 🎉

@dunglas dunglas deleted the relay-node branch December 22, 2017 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants