Skip to content

Commit

Permalink
Fix set header to JSON earlier in GraphQL response
Browse files Browse the repository at this point in the history
Update the GraphQL handler to set the Response Header to JSON ealier for
error messages to be returned as JSON and not text/html.

Fixes #519
  • Loading branch information
Sonna committed Feb 5, 2019
1 parent c033f5f commit 33e3ca7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion handler/graphql.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

w.Header().Set("Content-Type", "application/json")
var reqParams params
switch r.Method {
case http.MethodGet:
Expand All @@ -320,7 +321,6 @@ func (gh *graphqlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
w.Header().Set("Content-Type", "application/json")

ctx := r.Context()

Expand Down

0 comments on commit 33e3ca7

Please sign in to comment.