Skip to content

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

Merged
acao merged 1 commit intographql:masterfrom
asiffermann:fix/sdl-download-linebreaks-in-comment-lines
Jul 22, 2020
Merged

fix: 'addLineBreaks' regex in 'createSDL' to avoid line-breaking comment lines#1245
acao merged 1 commit intographql:masterfrom
asiffermann:fix/sdl-download-linebreaks-in-comment-lines

Conversation

@asiffermann
Copy link
Copy Markdown
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
Copy Markdown

CLAassistant commented Jun 24, 2020

CLA assistant check
All committers have signed the CLA.

@chaffeqa
Copy link
Copy Markdown

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
Copy Markdown
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
RenovZ pushed a commit to RenovZ/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