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

fix: 'addLineBreaks' regex in 'createSDL' to avoid line-breaking comment lines #1245

Merged

Conversation

asiffermann
Copy link
Contributor

@asiffermann asiffermann commented Jun 24, 2020

I have been using Playground for a while now with a GraphQL API developed in ASP.NET Core, using the open source library graphql-dotnet.

Everytime I download the SDL schema from Playground, there are several comment lines with line breaks in the middle, which makes the exported file invalid until I manually delete all unwanted line breaks.

After investigation, I found out that the library graphql-dotnet brings comments for scalar types containing the word "scalar" (like this one) or even with closing braces in it (for example the connection type).
So, those comment lines are matched by the regex in function addLineBreaks which then adds unwanted line breaks, resulting in the following invalid schema file (cut for clarity):

image
image

Changes proposed in this pull request:

  • Change breakBrackets regex to match opening braces only on beginning of lines (to add a line break after a type)
  • Change withLineBreaks regex to match the word 'scalar' only on beginning of lines and make it multiline

I hope my explanations are clear enough, and am looking forward to be able to export a valid SDL schema directly!
Thank you for your great work on this essential tool to develop GraphQL APIs!

@CLAassistant
Copy link

CLAassistant commented Jun 24, 2020

CLA assistant check
All committers have signed the CLA.

@chaffeqa
Copy link

I'm pretty sure this fixes the schema tab crashing. I found the offending line break comment in our schema, removed it, and the schema tab stopped crashing

@acao
Copy link
Member

acao commented Jul 22, 2020

thanks for this @asiffermann !

@acao acao merged commit f3b1e03 into graphql:master Jul 22, 2020
abernix pushed a commit to apollographql/graphql-playground that referenced this pull request Sep 8, 2020
cgxxv pushed a commit to cgxxv/graphql-playground that referenced this pull request Mar 25, 2022
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

Successfully merging this pull request may close these issues.

5 participants