graphql-go / graphql-go/graphql

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

Open
#677 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.1k
Forks
845
PR merge metrics
No merged PRs in 30d

Description

If [**Block String**](https://spec.graphql.org/October2021/#BlockStringCharacter) comment contains a double-quote, the resulting printed SDL will be invalid.

### Example problem

Suppose you have the following schema:

```graphql
"""
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`**](https://github.com/graphql-go/graphql/blob/v0.8.1/language/printer/schema_printer_test.go), then you end up with:

```graphql
"""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:

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.