GraphQL Query Execution
GraphQL query execution is the server-side process that takes an incoming query string, validates it against the schema, and resolves each requested field — potentially by calling multiple backing data sources — before assembling the final JSON response.
GraphQL query execution is the server-side process that takes an incoming query string, validates it against the schema, and resolves each requested field — potentially by calling multiple backing data sources — before assembling the final JSON response.
What the diagram shows
This sequence diagram follows a GraphQL request through five stages across four participants: Client, GraphQL Server, Resolver Layer, and Data Source (representing a database or external API).
1. Parse: the server tokenizes the raw query string into an Abstract Syntax Tree (AST). 2. Validate: the AST is checked against the schema. Field names, argument types, and nesting depth are all verified. If validation fails, the server returns an error immediately — no resolver is ever called. 3. Execute: the server walks the validated AST and dispatches each field to its registered resolver function. 4. Resolve: individual resolvers query databases, call microservices, or read from cache. Results bubble back up through the execution engine. 5. Respond: the server merges all resolver outputs into a single JSON object and returns it under the data key, with any partial errors in the errors array.
The diagram highlights the crucial validation short-circuit: a malformed or unauthorized query never reaches your data layer.
Why this matters
GraphQL's resolver-per-field execution model is powerful but non-obvious. Developers who treat it like a REST call often hit N+1 query problems because they don't realize each list item triggers its own resolver invocation. Visualizing the execution order makes the problem — and the DataLoader batching solution — immediately apparent.
For comparison, see the REST API Request Lifecycle to understand how a simpler handler-based approach differs. If GraphQL sits behind an API Gateway Request Flow, authentication can be offloaded before the query ever reaches the GraphQL layer. For data persistence details, see the database transaction lifecycle.