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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With