graphql-playground icon indicating copy to clipboard operation
graphql-playground copied to clipboard

GraphQL Playground Docs break on recursive types

Open SleeplessOne1917 opened this issue 4 years ago • 1 comments

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?

  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

SleeplessOne1917 avatar Aug 14 '21 19:08 SleeplessOne1917

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.

mikespub avatar Jun 05 '22 20:06 mikespub

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.

SleeplessOne1917 avatar Sep 23 '22 11:09 SleeplessOne1917