{"action":"created","issue":{"url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/21","labels_url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/21/comments","events_url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/21/events","html_url":"https://github.com/Folkloreatelier/laravel-graphql/issues/21","id":116862576,"number":21,"title":"Implementation of the \"Node Interface\" Relay specification","user":{"login":"soosap","id":7187705,"avatar_url":"https://avatars.githubusercontent.com/u/7187705?v=3","gravatar_id":"","url":"https://api.github.com/users/soosap","html_url":"https://github.com/soosap","followers_url":"https://api.github.com/users/soosap/followers","following_url":"https://api.github.com/users/soosap/following{/other_user}","gists_url":"https://api.github.com/users/soosap/gists{/gist_id}","starred_url":"https://api.github.com/users/soosap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soosap/subscriptions","organizations_url":"https://api.github.com/users/soosap/orgs","repos_url":"https://api.github.com/users/soosap/repos","events_url":"https://api.github.com/users/soosap/events{/privacy}","received_events_url":"https://api.github.com/users/soosap/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-11-13T22:04:48Z","updated_at":"2015-11-14T08:56:07Z","closed_at":null,"body":"Like @chrissm79, I am too trying to implement the Relay specifications set out for a GraphQL server. The [Relay Global Object Identification Specification](https://facebook.github.io/relay/graphql/objectidentification.htm) states the following:\r\n> The server must provide an interface called Node. That interface must include exactly one field, called id that returns a non‐null ID.\r\n\r\n> This id should be a globally unique identifier for this object, and given just this id, the server should be able to refetch the object.\r\n\r\nHere is my attempt to implement it:\r\n**NodeInterface.php**\r\n```php\r\n<?php namespace App\\GraphQL\\Types;\r\n\r\nuse GraphQL\\Type\\Definition\\Type;\r\nuse Folklore\\GraphQL\\Support\\Type as GraphQLType;\r\n\r\nclass NodeInterface extends GraphQLType\r\n{\r\n    protected $attributes = [\r\n        'name' => 'Node',\r\n        'description' => 'Node Interface'\r\n    ];\r\n\r\n    public function fields()\r\n    {\r\n        return [\r\n            'id' => [\r\n                'type' => Type::nonNull(Type::id()),\r\n                'description' => 'Id of the node'\r\n            ]\r\n        ];\r\n    }\r\n}\r\n```\r\n\r\n**graphql.php**\r\n```php\r\n    ...\r\n    'schema' => [\r\n        'query' => [\r\n            'node' => App\\GraphQL\\Queries\\NodeQuery::class,\r\n            'users' => App\\GraphQL\\Queries\\UsersQuery::class,\r\n        ],\r\n    ],\r\n    ...\r\n    'types' => [\r\n        'node' => App\\GraphQL\\Types\\NodeInterface::class,\r\n        'user' => App\\GraphQL\\Types\\UserType::class\r\n    ]\r\n    ...\r\n```\r\n\r\n**NodeQuery.php**\r\nThis, I suppose, is the place where the base64 encoded global id gets decoded into i.e. id+type information in your Laravel app using a helper function like `decodeGlobalIdField($args['globalId'])`. How can I access the `globalId` if I need it outside of the `resolve()` function? Do I need it outside of it? What do I return in the `type()` function?\r\n```php\r\n<?php namespace App\\GraphQL\\Queries;\r\n\r\nuse GraphQL;\r\nuse GraphQL\\Type\\Definition\\Type;\r\nuse Folklore\\GraphQL\\Support\\Query;\r\n\r\nclass NodeQuery extends Query {\r\n\r\n    protected $attributes = [\r\n        'name' => 'node'\r\n    ];\r\n\r\n    public function type()\r\n    {\r\n        return GraphQL::type('node');\r\n    }\r\n\r\n    public function args()\r\n    {\r\n        return [\r\n\r\n        ];\r\n    }\r\n\r\n    public function resolve($root, $args)\r\n    {\r\n\r\n    }\r\n\r\n}\r\n```\r\n\r\nAny hints and tips are helpful!\r\nAt the end of the day I try to rebuild the following introspection query:\r\n```\r\n{\r\n  __type(name: \"Node\") {\r\n    name\r\n    kind\r\n    fields {\r\n      name\r\n      type {\r\n        kind\r\n        ofType {\r\n          name\r\n          kind\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n... that shall lead to the following output:\r\n```\r\n{\r\n  \"__type\": {\r\n    \"name\": \"Node\",\r\n    \"kind\": \"INTERFACE\",\r\n    \"fields\": [\r\n      {\r\n        \"name\": \"id\",\r\n        \"type\": {\r\n          \"kind\": \"NON_NULL\",\r\n          \"ofType\": {\r\n            \"name\": \"ID\",\r\n            \"kind\": \"SCALAR\"\r\n          }\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}\r\n```\r\n\r\n**So far**, I am making the following introspection query:\r\n```\r\n{\r\n  __type(name: \"Node\"){\r\n    name\r\n    description\r\n    kind\r\n  }\r\n}\r\n```\r\n... for which I am yielding\r\n```\r\n{\r\n  \"data\": {\r\n    \"__type\": {\r\n      \"name\": \"Node\",\r\n      \"description\": \"Node Interface\",\r\n      \"kind\": \"OBJECT\"\r\n    }\r\n  }\r\n}\r\n```\r\nIf I'd had to cut my question short, what do I have to do for **\"kind\"** to return **\"INTERFACE\"** instead of **\"OBJECT\"**?"},"comment":{"url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/comments/156672174","html_url":"https://github.com/Folkloreatelier/laravel-graphql/issues/21#issuecomment-156672174","issue_url":"https://api.github.com/repos/Folkloreatelier/laravel-graphql/issues/21","id":156672174,"user":{"login":"soosap","id":7187705,"avatar_url":"https://avatars.githubusercontent.com/u/7187705?v=3","gravatar_id":"","url":"https://api.github.com/users/soosap","html_url":"https://github.com/soosap","followers_url":"https://api.github.com/users/soosap/followers","following_url":"https://api.github.com/users/soosap/following{/other_user}","gists_url":"https://api.github.com/users/soosap/gists{/gist_id}","starred_url":"https://api.github.com/users/soosap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/soosap/subscriptions","organizations_url":"https://api.github.com/users/soosap/orgs","repos_url":"https://api.github.com/users/soosap/repos","events_url":"https://api.github.com/users/soosap/events{/privacy}","received_events_url":"https://api.github.com/users/soosap/received_events","type":"User","site_admin":false},"created_at":"2015-11-14T08:56:07Z","updated_at":"2015-11-14T08:56:07Z","body":"Glad to hear, can't wait:) Have you checked whether you are able to re-produce the suggested introspection query by FB?"}}