fix: 'addLineBreaks' regex in 'createSDL' to avoid line-breaking comment lines#1245
Merged
acao merged 1 commit intographql:masterfrom Jul 22, 2020
Conversation
arnaudauroux
approved these changes
Jun 24, 2020
7 tasks
|
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 |
Member
|
thanks for this @asiffermann ! |
acao
approved these changes
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
addLineBreakswhich then adds unwanted line breaks, resulting in the following invalid schema file (cut for clarity):Changes proposed in this pull request:
breakBracketsregex to match opening braces only on beginning of lines (to add a line break after a type)withLineBreaksregex to match the word 'scalar' only on beginning of lines and make it multilineI 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!