graphql/graphql-over-http

Response status code as `application/json` content

TomokiMiyauci opened this issue · 5 comments

from https://graphql.github.io/graphql-over-http/draft/#sec-application-json

application/json
If the GraphQL response contains a non-null data entry then the server MUST use the 200 status code.

As an application/json content, if the data entry is null or none, what is the appropriate response status code?

In that case, the first rule of the section applies:

The server SHOULD use the 200 status code, independent of any GraphQL request error or GraphQL field error raised.

@spawnia Thanks for letting me know.

Aside: in application/graphql+json we say MUST 2xx, SHOULD 200. In application/json we say MUST 200. Is this definitely the behaviour we want to enforce? (I think it is, it just struck me as unexpected when quoted above!)

For the record, I understood the following.

Response status

application/graphql+json application/json
HTTP Request error 4XX(eg.406, 415) 4XX
GraphQL request error 400 200
GraphQL field error 200 200
Unknown(Internal server) error 5XX 5XX

Following the SHOULDs, that table is correct (I think).