Skip to content

Invalid GraphQL requests must result in HTTP 400 responses #568

Closed as not planned
@bclozel

Description

@bclozel

As explained in the GraphQL over HTTP spec:

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.

If the GraphQL request is invalid (e.g. it is malformed, or does not pass validation) then the server SHOULD reply with 400 status code.

Currently Spring for GraphQL responds with an HTTP 200 OK response in this case:

{
  "errors": [
    {
      "message": "Validation error (FieldUndefined@[spring]) : Field 'spring' in type 'Query' is undefined",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "extensions": {
        "classification": "ValidationError"
      }
    }
  ]
}

Metadata

Metadata

Assignees

Labels

in: webIssues related to web handlingstatus: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions