midGraphQL
How does error handling work in GraphQL?
Updated Apr 28, 2026
Short answer
GraphQL responses usually have two top-level keys: data and errors. Errors do not necessarily fail the entire request.
Deep explanation
If a resolver throws an error, the errors array is populated with the message, path, and locations. Because GraphQL allows partial success, the data object might still contain successfully resolved fields while the failed fields return null.
Real-world example
A user views a dashboard. The weather widget fails (returns error), but the user's profile data resolves perfectly. The app still renders the profile.
Common mistakes
- Relying on HTTP status codes (like 404 or 500) for GraphQL errors. Most GraphQL APIs return HTTP 200 OK even if the response contains severe resolver errors.
Follow-up questions
- What is the extensions key in an error?