graphql-playground
graphql-playground copied to clipboard
GraphQL Playground Docs break on recursive types
This issue pertains to the following package(s):
- [ ] GraphQL Playground - Electron App
- [ ] GraphQL Playground HTML
- [X] GraphQL Playground
- [ ] GraphQL Playground Express Middleware
- [ ] GraphQL Playground Hapi Middleware
- [ ] GraphQL Playground Koa Middleware
- [ ] GraphQL Playground Lambda Middleware
What OS and OS version are you experiencing the issue(s) on?
Windows 10 Build 19042
What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?
v2
What is the expected behavior?
I expect to be able to use the Docs tab to look at types that have a recursive reference in their field. For example, a Message type might have a comments field that returns a list of type Message.
What is the actual behavior?
If I go too deep into recursive fields in the docs, GraphQL Playground crashes and displays the following error in the console: react-dom.production.min.js:187 RangeError: Maximum call stack size exceeded
This only happens when using GraphQL Playground from www.graphqlbin.com. If I go directly to localhost to use the GraphQL Playground built into Apollo Server, I can use the docs for recursive fields without crashing.
What steps may we take to reproduce the behavior?
- Create a simple GraphQL api with a schema that has a type with a field that recursively returns that type.
- Go to www.graphqlbin.com
- Enter the address of the api you created
- Click on docs
- Click on a query that returns the recursive type
- Click on the field for the recursive reference. You may have to go a few clicks deep for the playground to crash.
The GraphQL Playground still seems to choke on recursive schema definitions like:
type Sample {
id: ID!
name: String
age: Int
location: String
partner: Sample
parents: [Sample]
children: [Sample]
}
In the HTML version, I have no problems executing queries after adding this to the schema, but:
- the schema & docs tabs are not refreshed,
- it keeps calling back with the introspection query despite the fact that it gets back results, and
- the URL shows Server cannot be reached.
The server is based on webonyx/graphql-php
Any ideas?
Update
After further investigation and reload, GraphQL Playground gave me a nice Error: Introspection must provide input type for arguments, which led me to the actual error in the schema - the corresponding Input Type:
input Sample_Input {
id: ID
name: String
age: Int
location: String
partner: Sample
parents: [Sample]
children: [Sample]
}
Changing those fields to Sample_Input too fixes the issue, thanks.
It seems that the breaking on recursive types was due to a problem with a tool I was using to generate the schema. I will close this now.