Skip to content

Inputs which use non-primitive default values crash the playground #903

Closed
@rDr4g0n

Description

@rDr4g0n

This issue pertains to the following package(s):

  • GraphQL Playground - Electron App
  • GraphQL Playground HTML
  • 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?

Ubuntu Linux 16.04, Chrome Version 70.0.3538.77 (Official Build) (64-bit)

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s)

1.7.10

What is the expected behavior?

App's schema explorer should be able to display inputs which include non-primitive default values. eg:

    input BInput {
        first: Int
        last: Int
    }
    input AInput {
        id: ID
        b: BInput = {
            first: 10
        }
    }

Navigating in the schema explorer to the example AInput schema should not crash the app.

What is the actual behavior?

When attempting to view the AInput schema, app crashes with Cannot convert object to primitive value at the following line:
https://github.com/prisma/graphql-playground/blob/master/packages/graphql-playground-react/src/components/Playground/DocExplorer/TypeLink.tsx#L169

type.defaultValue evaluates to { first: 10 }.

What steps may we take to reproduce the behavior?

Create a schema with a input that contains a non-primitive default as demonstrated above, then attempt to view it in the schema viewer in the playground

Note that the example input AInput is a simplified example of MetricsInput which appears in the gif. They both have in common that they use a non-primitive default value.
playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions