fsprojects / FSharp.Data.GraphQL

FSharp implementation of Facebook GraphQL query language.
http://fsprojects.github.io/FSharp.Data.GraphQL/
MIT License
399 stars 73 forks source link

Bug: single quotes as a value are currently not supported in input strings. #401

Closed valbers closed 1 year ago

valbers commented 1 year ago

Description

Single quotes are not considered valid string values, but should be.

Repro steps

Just try to use single quotes in any input string in a query/mutation/subscription.

Alternative reproduction:

Expected behavior

Single quotes should be considered a valid character in an input string.

Actual behavior

Parser exception is thrown. Example:

[xUnit.net 00:00:01.27]     FSharp.Data.GraphQL.Tests.ParserTests.parser should parse query with single-quoted arguments [FAIL]
  Fehler FSharp.Data.GraphQL.Tests.ParserTests.parser should parse query with single-quoted arguments [77 ms]
  Fehlermeldung:
   System.FormatException : Error in Ln: 2 Col: 22
    search(query: "It's working!") {
                     ^
Expecting: any char not in ‘ "'’, '"' or '\\'

  Stapelverfolgung:
     at FSharp.Data.GraphQL.Parser.parse(String query) in /Users/valber/dev/forks/FSharp.Data.GraphQL/src/FSharp.Data.GraphQL.Shared/Parser.fs:line 321
   at FSharp.Data.GraphQL.Tests.ParserTests.test(Document ast, String query) in /Users/valber/dev/forks/FSharp.Data.GraphQL/tests/FSharp.Data.GraphQL.Tests/ParserTests.fs:line 13
   at FSharp.Data.GraphQL.Tests.ParserTests.parser should parse query with single-quoted arguments() in /Users/valber/dev/forks/FSharp.Data.GraphQL/tests/FSharp.Data.GraphQL.Tests/ParserTests.fs:line 316

Known workarounds

I don't know what people are using as a workaround. An ugly workaround would be to encode every input string at the client and decode it at the server (ugh!)

Related information