Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graphql : Failing on wrong content-type message #5174

Closed
ardan-bkennedy opened this issue Apr 11, 2020 · 5 comments
Closed

Graphql : Failing on wrong content-type message #5174

ardan-bkennedy opened this issue Apr 11, 2020 · 5 comments
Labels
area/graphql Issues related to GraphQL support on Dgraph. area/integrations Related to integrations with other projects. status/accepted We accept to investigate/work on it.

Comments

@ardan-bkennedy
Copy link

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.

https://github.com/machinebox/graphql/blob/v0.2.2/graphql.go#L117

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.

https://github.com/dgraph-io/dgraph/blob/master/dgraph/cmd/alpha/http.go#L179

@MichelDiz
Copy link
Contributor

MichelDiz commented Apr 11, 2020

why don't you try like this?

	req.Header.Set("content-type", "application/json")
	req.Header.Set("charset", "utf-8")

@ardan-bkennedy
Copy link
Author

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.

@MichelDiz
Copy link
Contributor

MichelDiz commented Apr 12, 2020

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.

@MichelDiz MichelDiz added area/graphql Issues related to GraphQL support on Dgraph. area/integrations Related to integrations with other projects. status/accepted We accept to investigate/work on it. labels Apr 12, 2020
@MichaelJCompton
Copy link
Contributor

Not sure if this is happening for GraphQL calls to /graphql, or GraphQL+- calls, or both. We'll pick it up.

@minhaj-shakeel
Copy link
Contributor

Github issues have been deprecated.
This issue has been moved to discuss. You can follow the conversation there and also subscribe to updates by changing your notification preferences.

drawing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql Issues related to GraphQL support on Dgraph. area/integrations Related to integrations with other projects. status/accepted We accept to investigate/work on it.
Development

Successfully merging a pull request may close this issue.

4 participants