How does error handling work in GraphQL?
Assesses fundamental understanding of GraphQL conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
GraphQL usually returns HTTP 200 with a JSON body containing data and/or errors, because a single operation can partially succeed across fields.
{
"data": { "user": { "name": "Ada", "email": null } },
"errors": [
{ "message": "Email not visible",
"path": ["user", "email"],
"extensions": { "code": "FORBIDDEN" } }
]
}
Each error may include path, locations and extensions. Use extensions.code for stable, machine-readable categories, and avoid leaking internal messages. Null bubbling matters: if a non-null field resolves to null, the null propagates up to the nearest nullable ancestor, which can wipe out large parts of data.
For transport failures such as authentication, returning a 401 is still appropriate. Many teams adopt an explicit result union for mutations so domain errors are typed instead of hidden in the errors array.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.