diggy
(Dgraph Bot)
1
Moved from GitHub dgraph/5174
Posted by ardan-bkennedy:
What version of Dgraph are you using?
v20.03.0
Have you tried reproducing the issue with the latest release?
Yes
What is the hardware spec (RAM, OS)?
Mac for client and running dgraph/standalone in a container
Steps to reproduce the issue (command/config used to run Dgraph).
This code is making a graphql call using Machine-Box and it is failing with the following error.
https://play.golang.org/p/T6YVYIs3AOD
Unsupported Content-Type. Supported content types are application/json, application/graphql+-
This is not accurate since Machine-Box is setting the content-type
properly on line 117. Machine-Box sets the content-type
in the http call like this.
113 r, err := http.NewRequest(http.MethodPost, c.endpoint, &requestBody)
114 if err != nil {
115 return err
116 }
117 r.Header.Set("Content-Type", "application/json; charset=utf-8")
118 r.Header.Set("Accept", "application/json; charset=utf-8")
119 for key, values := range req.Header {
120 for _, value := range values {
121 r.Header.Add(key, value)
122 }
123 }
124 c.logf(">> headers: %v", r.Header)
As you can see, the content-type
is correct. Adding the charset should not cause Dgraph to fail.
Expected behaviour and actual result.
The code provided should work. The code inside of dgraph that is not parsing the content-type
correctly can be found here.
diggy
(Dgraph Bot)
2
MichelDiz commented :
why don’t you try like this?
req.Header.Set("content-type", "application/json")
req.Header.Set("charset", "utf-8")
diggy
(Dgraph Bot)
3
ardan-bkennedy commented :
I don’t own the Machine-Box api so that is not an option.
I know Dgraph wants to support as many API’s that are out there. I assume the Machine-Box API is working with other database.
I am not sure what the graphql spec says on the subject of setting the content-type.
diggy
(Dgraph Bot)
4
MichelDiz commented :
Got it, okay I gonna put your ticket in backlog and ping someone on the core team who is working in the GraphQL code.
PS. But I’m not sure why to use it, as JSON is by default encoded as UTF-8. Feels like redundant.
Cheers.
diggy
(Dgraph Bot)
5
MichaelJCompton commented :
Not sure if this is happening for GraphQL calls to /graphql, or GraphQL± calls, or both. We’ll pick it up.