I try to implement the relay example from https://facebook.github.io/relay/docs/graphql-relay-specification.html#content
In the example the query contains a node which is a interface. I try to do the same but getting
Error: Generated Schema cannot use Interface or Union types for execution.
at GraphQLInterfaceType.cannotExecuteSchema [as resolveType] (/Users/myProject/node_modules/graphql/utilities/buildASTSchema.js:476:9)
at completeAbstractValue (/Users/myProject/node_modules/graphql/execution/execute.js:649:57)
at completeValue (/Users/myProject/node_modules/graphql/execution/execute.js:592:12)
at /Users/myProject/node_modules/graphql/execution/execute.js:554:14
at process._tickCallback (internal/process/next_tick.js:103:7)
interface Node {
id: ID!
}
type Query {
me: User
user(id: ID!): User
node(id: ID!): Node
}
type User implements Node {
id: ID!
givenName: String
familyName: String
}
query{node(id:"eyJrZXkiOiJ1c2VyIiwidmFsdWUiOjF9"){
id
...myFragment
}}
fragment myFragment on User {
familyName
}
{
"data": {
"node": null
},
"errors": [
{
"message": "Generated Schema cannot use Interface or Union types for execution.",
"locations": [
{
"line": 1,
"column": 7
}
],
"path": [
"node"
]
}
]
}
What am i missing here?
Turned out i needed to define a resolver for Node. Ive done this using graphql-tools as mentioned
here http://dev.apollodata.com/tools/graphql-tools/resolvers.html
Most helpful comment
Turned out i needed to define a resolver for
Node. Ive done this using graphql-tools as mentionedhere http://dev.apollodata.com/tools/graphql-tools/resolvers.html