graphql / graphql-playground

🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
MIT License
8.75k stars 730 forks source link

GraphQL Playground Docs break on recursive types #1342

Closed SleeplessOne1917 closed 1 year ago

SleeplessOne1917 commented 3 years ago

This issue pertains to the following package(s):

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?

  1. Create a simple GraphQL api with a schema that has a type with a field that recursively returns that type.
  2. Go to www.graphqlbin.com
  3. Enter the address of the api you created
  4. Click on docs
  5. Click on a query that returns the recursive type
  6. Click on the field for the recursive reference. You may have to go a few clicks deep for the playground to crash.
playground error
mikespub commented 2 years ago

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 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.

SleeplessOne1917 commented 1 year ago

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.