7. How the router resolves data


So far, we've mainly been focused on our subgraphs. Now it's time!

We know that the uses the to resolve incoming GraphQL s from the client. But how exactly does that process work?

In this lesson, we will:

  • Trace the journey of a client request through the supergraph
  • Describe how the router creates query plans to resolve GraphQL operations across multiple subgraphs

The journey of a GraphQL operation through the supergraph

Let's start at the beginning: from the client request.

Step 1: The client request

First, the client sends a GraphQL to the . The client has no clue which s belong to which subgraphs—or even that there are subgraphs at all!

Step 1: The client sends a GraphQL operation to the router

Step 2: Building a query plan

The looks at the s in the and uses the to figure out which subgraphs are responsible for resolving each .

The router uses the supergraph schema

It uses this information to build a query plan, a list of smaller GraphQL s to execute on the subgraphs. The query plan also specifies the order in which the subgraph s need to run.

The router builds a query plan

Step 3: Executing the query plan

Next, the carries out the query plan by sending the smaller GraphQL s to each of the subgraphs it needs data from.

The router carries out the query plan

The subgraphs resolve the s the same way as any other GraphQL server: they use their s and s to retrieve and populate the requested data.

The subgraphs resolve the operations

Step 4: The subgraph responses

The subgraphs send back the requested data to the , and then the combines all those responses into a single JSON object.

The subgraphs send back the requested data to the router

Step 5: Sending data back to the client

Finally, the sends the final JSON object back to the client. And that's the end of our 's journey!

The router sends the final JSON object back to the client


Here's the entire journey of a GraphQL through the , summarized in a single diagram:

federated graph query animations


Which of the following statements are true?

Key takeaways

  • The router uses the supergraph schema to create a query plan for the incoming GraphQL operation. The query plan is a list of smaller operations the router can execute on different subgraphs to fully resolve the incoming operation.
  • The router carries out the query plan by executing the list of operations on the appropriate subgraphs.
  • The router combines all the responses from the subgraphs into a single JSON object, which it sends back to the client.

Up next

Coming up next, we're going to configure the to poll Apollo Uplink for our , and we'll finally begin querying our !