Ratel sends incorrect query to Dgraph v1.0.x

Moved from GitHub ratel/219

Posted by danielmai:

A user reported this error when running Dgraph v1.0.14 with Ratel. When they send a query they get the following error. This happens on Ratel ?dev, ?latest, and ?local.

Error Name: t
Message: Expected some name. Got: lex.Item [1] "while lexing {\"query\":\"{\\n exampleQuery(func:has(userType), first:10){\\n \\tuid\\n \\tfirstName\\n \\tlastName\\n\\t}\\n}\",\"variables\":{}}: Unrecognized character in lexText: U+0022 '\"'"
Raw Error:
{
  "name": "t",
  "url": "http://localhost:8080/query?timeout=20s&debug=true",
  "errors": [
    {
      "code": "ErrorInvalidRequest",
      "message": "Expected some name. Got: lex.Item [1] \"while lexing {\\\"query\\\":\\\"{\\\\n  exampleQuery(func:has(userType), first:10){\\\\n  \\\\tuid\\\\n  \\\\tfirstName\\\\n  \\\\tlastName\\\\n\\\\t}\\\\n}\\\",\\\"variables\\\":{}}: Unrecognized character in lexText: U+0022 '\\\"'\""
    }
  ]
}
Error

Dgraph v1.0.x and earlier does not support queries in the JSON format {"query": "...", "variables": "..."}. This was introduced in the HTTP API in Dgraph v1.1.0 and later to pass GraphQL variables.

I couldn’t reproduce this. Any ideas? It seems like Ratel mis-detected the version of Dgraph here and tried using the new HTTP API in v1.1.0 and And the user said that ?local didn’t work either which is odd.

paulftw commented :

Tried on play latest with Dgraph v1.0.14 and v1.0.16 and it worked both times.
Even adding query variables through the new UI worked as expected.

@danielmai, can you please ask them to try sending that query from https://play.dgraph.io/?latest. ?
And also ask them to provide the Ratel’s build TS and commit Id they are seeing in Ratel’s help?

What is the version of the server they are seeing in the Ratel network tab? Does it say 1.0.15-??? ?

Screen Shot 2020-06-30 at 6 04 40 PM