graphql-rust / graphql-parser

A graphql query language and schema definition language parser and formatter for rust
Apache License 2.0
355 stars 77 forks source link

Block string parsing doesn't conform to GraphQL spec. #74

Closed fpacanowski closed 11 months ago

fpacanowski commented 1 year ago

Currently the following block string:

"""

  Hello,
    World!

  Yours,
    GraphQL.

"""

gets parsed as "\nHello,\n World!\n\nYours,\n GraphQL.\n\n".

GraphQL specification requires the leading and trailing empty lines (i.e. lines containing only whitespace) to be stripped from block string value. Quoting the [block string spec](https://spec.graphql.org/October2021/#BlockStringValue()):

4. While the first item line in lines contains only WhiteSpace:
    a. Remove the first item from lines.

5. While the last item line in lines contains only WhiteSpace:
    a. Remove the last item from lines.

So the above block string should be parsed as "Hello,\n World!\n\nYours,\n GraphQL.".