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
Unable to make cross links between types #23
Comments
Also GraphQL type could reference to itself. |
GraphQL types can refer to themselves by implementing var RecursiveType = new GraphQLObjectType({
name: 'Recursive',
fields: {
recurse: { type: RecursiveType }
}
}); Will not work because you reference var RecursiveType = new GraphQLObjectType({
name: 'Recursive',
fields: function () {
return {
recurse: { type: RecursiveType }
}
}
}); Or if you're using ES6 arrow functions var RecursiveType = new GraphQLObjectType({
name: 'Recursive',
fields: () => ({
recurse: { type: RecursiveType }
})
}); The function is called after the type is defined, ensuring the variable has been set before it is referenced. |
@leebyron Thank you very much for quick reply! |
@leebyron Very helpfull, thanks! |
Thanks for the tips here. What if I'm declaring a I have a NestedType with a 'parent' attribute that is defined as a UnionParentType.
When I run this - It doesn't work. Is it possible to work recursively like this with union types? |
The
I was also getting an error like:
It was fixed by changing |
Vectors in graph could reference to each other in any direction.
So I should be able to use GraphQL type before it's implementation.
I don't found a possibility to do this right now. Am I right?
The text was updated successfully, but these errors were encountered: