jamesmacaulay / elm-graphql

A GraphQL library for Elm
http://package.elm-lang.org/packages/jamesmacaulay/elm-graphql/latest
BSD 3-Clause "New" or "Revised" License
313 stars 19 forks source link

\n in the request json #40

Closed Ulrar closed 6 years ago

Ulrar commented 6 years ago

Hi,

Might be doing it wrong, but it looks like the json sent to the server contains the actual \n characters instead of regular line breaks, which breaks parsing on the server. Here is the raw query as seen from Firefox's "edit and resend", which is the only I found to get the raw request :

{"query":"query {\n projects {\n name\n }\n}"}

The ELM code for that query :

projectsRequest =
  let project = list (
      object Project
      |> with (field "name" [] string)
      )
  in
  extract (field "projects" [] project) |> queryDocument |> request {}

Using the latest firefox 62, if that matters.

jamesmacaulay commented 6 years ago

That's the standard way to serialize strings in JSON, and is the same format that your browser's built-in JSON.stringify gives you. What server are you using? I think the problem must be with the JSON parsing code on the server.

jamesmacaulay commented 6 years ago

Closing the issue for now since I don't think this is a bug in the package.