Skip to content

Graphql : Failing on wrong content-type message #5174

@ardan-bkennedy

Description

@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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/graphqlIssues related to GraphQL support on Dgraph.area/integrationsRelated to integrations with other projects.status/acceptedWe accept to investigate/work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions