elm-graphql
elm-graphql copied to clipboard
betweenQuotes must also encode special characters.
The betweenQuotes function seems to be incorrect as e.g. \n should be encoded as \\n, but all it does is to add the surrounding escape quotes.
Here is a list of all JSON special characters: https://www.tutorialspoint.com/json_simple/json_simple_escape_characters.htm
Do you know if there's a builtin function, or something to do the escaping directly in Elm?
Yeah, it's actually just simple JSON encoding the string, so Json.Encode.encode does the job. (https://package.elm-lang.org/packages/elm/json/1.1.3/Json-Encode#encode)
I guess that means betweenQuotes can simply be replaced with encode 0 😅
I'll try to ship a new version that WE
The quick workaround is to replace |> GQL.string with
|> JE.string
|> JE.encode 0
|> GQL.type_