graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.82k stars 836 forks source link

Printer returns invalid SDL if Block String comment contains double-quote #677

Open kevinmichaelchen opened 10 months ago

kevinmichaelchen commented 10 months ago

If Block String comment contains a double-quote, the resulting printed SDL will be invalid.

Example problem

Suppose you have the following schema:

"""
Representation of a "Foo"
"""
type Foo {
  name: String
}

if you parse this schema to an AST document, and then print the document to an SDL string (as shown in schema_printer_test.go, then you end up with:

"""Representation of a "Foo""""
type Foo {
  name: String
}

Notice the extra double-quote 😢

Example solution

One workaround is to remove the double quotes from the comment.

Even something like this would work fine:

"""
Representation of a Foo
"""
type Foo {
  name: String
}