SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
805 stars 171 forks source link

Align GraphQL Response Content Types and Status Codes with Specification #484

Closed ujibang closed 11 months ago

ujibang commented 11 months ago

Describe the bug

The GraphQL API is not consistent with the GraphQL Over HTTP specs

Specifically:

The server SHOULD NOT use a 4xx or 5xx status code for a response to a well-formed GraphQL-over-HTTP request.

To Reproduce

Steps to reproduce the behavior:

  1. Execute the test case "Should contains errors key" in field-to-aggregation.feature
  2. The status code is 400

Expected behavior

The response codes should adhere to the specifications.

Detailed documentations

the response content type from the GraphQL API is now always application/graphql-response+json

the API response codes are:

For the last case the specification says:

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

jodeleit-es commented 11 months ago

I assume the first link has a wrong target. Did you want to link to this URL? --> https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#applicationjson