Skip to content

Status codes 404 and 410 #234

Description

@saerdnaer

Just to clarify: What would be the correct behaviour for a root level resolver which did not find and matching records (404), or knows that the requested record is no longer available (410)?

https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#applicationgraphql-responsejson

This section only applies when the response body is to use the application/graphql-response+json media type.

If the GraphQL response contains the {data} entry and it is not {null}, then the server MUST reply with a 2xx status code and SHOULD reply with 200 status code.

If the GraphQL response contains the {data} entry and it is {null}, then the server SHOULD reply with a 2xx status code and it is RECOMMENDED it replies with 200 status code.

Note: Using 4xx and 5xx status codes in this situation is not recommended - since no GraphQL request error has occurred it is seen as a "partial response".

If the GraphQL response does not contain the {data} entry then the server MUST reply with a 4xx or 5xx status code as appropriate.

Note: The GraphQL specification indicates that the only situation in which the GraphQL response does not include the {data} entry is one in which the {errors} entry is populated.

So I either have to return

  • 200 { "data": null } or
  • 404 { "errors": [ {"message": "item could not be found"} ] } /
  • 410 { "errors": [ {"message": "item is no longer available"} ] }
    to conform to the specs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions