Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Graphene Django "Must provide query string"

I have setup a Graphene server using Django. When I run my queries through GraphiQL (the web client), everything works fine. However, when I run from anywhere else, I get the error: "Must provide query string."

I did some troubleshooting. GraphiQL sends POST data to the GraphQL server with Content-Type: application/json. Here is the body of the request that I copied from Chrome network tab for GraphiQL:

{"query":"query PartnersQuery {\n  partners{\n    name\n    url\n    logo\n  }\n}","variables":"null","operationName":"PartnersQuery"}

When I copy it to Postman with Content-Type: application/json, I get the following response:

{
  "errors": [
    {
      "message": "Must provide query string."
    }
  ]
}

What can be the cause of this problem? I have not done anything crazy with the schema. Just followed the tutorials from graphene's docs. What else can cause an issue like this?

like image 713
Gasim Avatar asked May 25 '17 16:05

Gasim


1 Answers

This error is raised when parse_body is unable to parse the incoming data. I'd start there by looking at the data passed into this method and ensuring it's of the correct type.

For example, the multipart/form-data section naively returns request.POST, which may need to be overwritten to handle, for example, the request that apollo-upload-client sends for file upload handling. In our case we created a view to both require a login and to support the apollo-upload-client use case and it works fine.

like image 136
Adam Donahue Avatar answered Sep 30 '22 00:09

Adam Donahue