graphql / graphql-playground

🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
MIT License
8.77k stars 735 forks source link

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

Closed asiffermann closed 4 years ago

asiffermann commented 4 years ago

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:

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 commented 4 years ago

CLA assistant check
All committers have signed the CLA.

chaffeqa commented 4 years ago

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 commented 4 years ago

thanks for this @asiffermann !