graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

ValueToJSON may emit invalid JSON for block strings

Open dnerdy opened this issue 3 years ago • 2 comments

As mentioned in #295, raw string content in the AST is unquoted in block strings, but the ValueToJSON method assumes string content is quoted. This means invalid JSON may be produced when block strings are serialized to JSON.

For example, the following GraphQL block string:

"""Hello
there"""

will be serialized to JSON as:

"Hello
there"

It should instead be:

"hello\nthere"

dnerdy avatar Oct 25 '21 22:10 dnerdy

is this fixed?

jensneuse avatar Jan 14 '22 09:01 jensneuse

No. #295 made it so triple quotes are preserved in GraphQL documents, but triple-quoted strings may not be valid when serialized to JSON.

dnerdy avatar Jan 14 '22 21:01 dnerdy