3. Journey of a GraphQL operation
1m

How does a GraphQL server handle incoming client requests?

  1. Browser sends GraphQL operation to server in a regular HTTP request. The GraphQL operation is just a string.
  2. Server parses the string and converts it to something easier to work with: an abstract syntax tree (AST).
  3. Server validates that the GraphQL operation from the client is acceptable by comparing the AST against the schema, which stores the types and fields for how the API is structured (in other words, what data clients can ask for).
  • If validation errors, return an error to the browser, and the journey stops there.
  1. If validation succeeds, resolver functions populate the data for each requested field by retrieving data from other data sources (REST APIs, databases, etc)
  2. Server sends back a single JSON object with all the requested data to the browser
A digital hand-drawn diagram of how a GraphQL operation moves from the client to the GraphQL server back to the client. (Detailed description in the blog post linked below.)

Resources:

  • Apollo Blog: Journey of a GraphQL query

In what order does the server do the following steps?

 
 
 
 
 

Drag items from the box to the blanks above

Build an AST
Resolve the data
Parse the query
Return the results
Validate the query
Previous
Next