graphql / graphql-playground

🎮 GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)
MIT License
8.77k stars 735 forks source link

Body encased in error Object when status Code is 401 #898

Open niklasR opened 5 years ago

niklasR commented 5 years ago

This issue pertains to the following package(s):

What OS and OS version are you experiencing the issue(s) on?

Mac OS 10.14.1

What version of graphql-playground(-electron/-middleware) are you experiencing the issue(s) on?

Version 1.8.4

What is the expected behavior?

Show Body as it is returned by the server as

{
  "data": {}
}

What is the actual behavior?

Body shown in error object

{
  "error": {
    data: {}
  }

}

What steps may we take to reproduce the behavior?

Set up a GraphQL server that returns a 401 status code without a graphQL error in the body.

Gif showing the same 200 and 401 responses rendered differently: graphql-bug

richardscarrott commented 4 years ago

Just spent two hours trying to debug ApolloServer error formatting because of this, FML.

richardscarrott commented 4 years ago

(NOTE: it also happens for 400 status codes, e.g. GRAPHQL_VALIDATION_FAILED)

justinvoelker commented 4 years ago

This appears to happen with all non-success status codes. Also, it is happening on the HTML client delivered via CDN.