⬡ GraphQL Beginner

What is the GraphQL response format?

Answer

GraphQL responses always follow a standardized JSON format regardless of success or failure. The response object has up to three top-level fields: (1) data: the result of the operation — mirrors the query structure exactly. Present on success; may be null if a non-null field errored. (2) errors: an array of error objects when something goes wrong. Each error has: message (required), locations (query position), path (path to the errored field), extensions (custom metadata like error codes). Critically, GraphQL can return both data and errors simultaneously — partial success is possible (some fields succeed, others fail). (3) extensions: optional metadata (tracing info, cache hints). HTTP status is almost always 200 even for errors — clients must check the errors array.