Skip to content
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

Schema view is broken when schema.disableComments is true #1115

Open
2 tasks
Mikhus opened this issue Dec 23, 2019 · 0 comments
Open
2 tasks

Schema view is broken when schema.disableComments is true #1115

Mikhus opened this issue Dec 23, 2019 · 0 comments

Comments

@Mikhus
Copy link

Mikhus commented Dec 23, 2019

This issue pertains to the following package(s):

  • GraphQL Playground - Electron App
  • GraphQL Playground

What OS and OS version are you experiencing the issue(s) on?

Linux

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

1.7.31 and from master branch

What is the expected behavior?

Schema view displays schema

What is the actual behavior?

Empty screen, Syntax error in web browser console

What steps may we take to reproduce the behavior?

Have a schema with comments like this

# Defined queries available
type Query {
  # Fetches an object given its ID
  # **@namespace**: common
  #
  Node(
    # The ID of an object
    id: ID!
  ): Node
}

I found, that problem is caused by this line of code in packages/graphql-playground-react/src/components/Playground/util/createSDL.ts at line 92:

const sdlWithNewLines = rawSdl.replace(/(\#[\w\'\s\r\n\*](.*)$)/gm, '')

If to comment it out everything works fine, but comments are preserved. So I think there is a problem in regexp which does the jom. Actually, because I have empty-line comment it also removes the next line, so schema code looks like this:


type Query {




 
    id: ID!
  ): Node
}

which is definitely broken schema.

I use apollo-graphql-express as Apollo server, so it can be fixed by forcing "schema.disableComments": false from server side to make sure initial load will not cause a problem, but if user change this property locally - bug happen! Of course, I can fix it by removing new lines from comments, BTW, despite this fact there is a buggy software behavior...

Server is based on code-first schema generation, so the javascript schema is provided to server instance instead of typeDefs and resolvers. So schema code is built on playground side itself (guess with printSchema...)

This also causes the need to restart electron app, as there is no way to get back or close the blank scree after pressing "Schema" button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant