Skip to content

docs: add guide on graphql-http errors #2006

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: source
Choose a base branch
from

Conversation

sarahxsanders
Copy link
Contributor

Description

  • Adds guide on graphql-http errors (just some common ones) and how to debug them
  • Adds block on Best Practices landing page

Feel free to suggest additional common errors if there are any that might be important to highlight here!

Copy link

vercel bot commented May 30, 2025

@sarahxsanders is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel.

A member of the Team first needs to authorize it.

@sarahxsanders sarahxsanders marked this pull request as ready for review May 30, 2025 18:22
@saihaj saihaj requested a review from enisdenjo June 2, 2025 14:24
Copy link
Member

@benjie benjie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really good general reference that should be applicable to any server implementing GraphQL-over-HTTP (not just the reference implementation).

One concern is it does not incorporate the application/graphql-response+json media type. Since the spec is currently a draft I wouldn't normally be too concerned, except we do link to the spec so we should recommend its recommendations.

### Common causes

- Sending a `PUT` or `DELETE` request instead of `POST` or `GET`
- Sending a `GET` request for a mutation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Sending a `GET` request for a mutation
- Sending a `GET` request for a mutation, or to a server that only supports `POST` requests


### What it means

The HTTP layer succeeded, but the GraphQL response contains errors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The HTTP layer succeeded, but the GraphQL response contains errors.
The HTTP layer succeeded, but the GraphQL request produced errors.


```json
{
"data": null,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A query that fails validation will never have a data property:

Suggested change
"data": null,


- Querying a field that doesn't exist
- Passing incorrect arguments to a field
- Violating schema constraints, such as non-nullability
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Violating schema constraints, such as non-nullability
- Violating schema constraints, such as non-nullability
- Runtime errors during execution


### How to debug

Check the `errors` array in the response body. A typical response looks like:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Check the `errors` array in the response body. A typical response looks like:
Check the `errors` array in the response body.
If the response includes a `data` property then your query document is likely valid and you most likely hit a runtime exception - perhaps something went wrong on the server, you supplied invalid data, you're not allowed to do that, or some other runtime exception occurred.
If the response does not include a `data` property it's likely there was a mistake in your request - an invalid GraphQL document or bad values for variables. A typical validation error response looks like:

@@ -0,0 +1,134 @@
# Common `graphql-http` Errors and How to Debug Them
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Common `graphql-http` Errors and How to Debug Them
# Common HTTP Errors and How to Debug Them

Comment on lines +7 to +11
This guide outlines common `graphql-http` errors, what they mean, and how to debug them
effectively. These examples assume you're using the
[GraphQL over HTTP specification](https://graphql.github.io/graphql-over-http/draft/)
and an implementation such as [`graphql-http`](https://github.com/graphql/graphql-http) or any
server that follows the spec.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This guide outlines common `graphql-http` errors, what they mean, and how to debug them
effectively. These examples assume you're using the
[GraphQL over HTTP specification](https://graphql.github.io/graphql-over-http/draft/)
and an implementation such as [`graphql-http`](https://github.com/graphql/graphql-http) or any
server that follows the spec.
This guide outlines common errors, what they mean, and how to debug them
effectively. These examples relate to servers that implement the
[GraphQL over HTTP specification](https://graphql.github.io/graphql-over-http/draft/). Different servers may produce different error messages and status codes in some circumstances, so this document should be treated as a general guide rather than a canonical reference.

type: "separator",
title: "GraphQL over HTTP",
},
"debug-errors": "Common `graphql-http` Errors",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"debug-errors": "Common `graphql-http` Errors",
"debug-errors": "Common GraphQL over HTTP Errors",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants