0
0
GraphQLquery~10 mins

Why federation scales GraphQL - Visual Breakdown

Choose your learning style9 modes available
Concept Flow - Why federation scales GraphQL
Client sends query
Gateway receives query
Gateway splits query by service
Send subqueries to respective services
Services resolve subqueries
Gateway collects and merges responses
Gateway returns combined result to client
The gateway breaks a big query into smaller parts, sends them to different services, then merges results to handle large GraphQL schemas efficiently.
Execution Sample
GraphQL
query {
  user(id: "1") {
    name
    reviews {
      product {
        name
      }
    }
  }
}
A client requests user info and their product reviews, which the gateway splits and sends to user and review services.
Execution Table
StepActionServiceQuery PartResponseGateway State
1Receive full queryGatewayFull queryN/AHolds full query
2Split queryGatewayuser(id: "1") { name }N/APrepares user subquery
3Split queryGatewayuser(id: "1") { reviews { product { name } } }N/APrepares review subquery
4Send subqueryUser Serviceuser(id: "1") { name }{"user": {"name": "Alice"}}Waiting for review response
5Send subqueryReview Serviceuser(id: "1") { reviews { product { name } } }{"reviews": [{"product": {"name": "Book"}}]}Has user and review data
6Merge responsesGatewayN/ACombined user and reviews dataReady to respond
7Return combined resultGatewayN/A{"user": {"name": "Alice", "reviews": [{"product": {"name": "Book"}}]}}Query complete
💡 All subqueries resolved and merged, gateway returns full response to client
Variable Tracker
VariableStartAfter Step 2After Step 4After Step 5Final
fullQueryFull client queryFull client queryFull client queryFull client queryFull client query
userSubqueryN/Auser(id: "1") { name }Sent to User ServiceReceived user dataMerged in final response
reviewSubqueryN/Auser(id: "1") { reviews { product { name } } }WaitingSent to Review ServiceMerged in final response
responsesEmptyEmpty{"user": {"name": "Alice"}}{"user": {"name": "Alice"}, "reviews": [{"product": {"name": "Book"}}]}Complete combined data
Key Moments - 3 Insights
Why does the gateway split the query instead of sending it whole to one service?
Because each service owns part of the schema, splitting lets each service handle only its data, improving scalability and separation (see execution_table steps 2 and 3).
How does the gateway know how to merge responses correctly?
The gateway uses the schema federation metadata to combine fields from different services into one response, as shown in step 6 where responses are merged.
What happens if one service is slow or fails?
The gateway waits for all subqueries; if one is slow, the whole query response is delayed. Federation allows independent scaling to reduce such delays.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step does the gateway send the user subquery to the User Service?
AStep 4
BStep 2
CStep 5
DStep 6
💡 Hint
Check the 'Action' and 'Service' columns in execution_table rows
According to variable_tracker, what is the state of 'responses' after Step 5?
AEmpty
BContains only user data
CContains user and review data
DMerged final response
💡 Hint
Look at the 'responses' row under 'After Step 5' column
If the gateway did not split the query, what would likely happen?
AThe query would be faster because it's sent once
BOne service would handle the entire query, reducing scalability
CThe gateway would merge responses from multiple services
DThe client would receive partial data only
💡 Hint
Refer to key_moments explanation about query splitting and service ownership
Concept Snapshot
GraphQL federation splits a big query into smaller parts.
Each part goes to the service owning that data.
Services resolve their parts independently.
Gateway merges all responses into one.
This lets GraphQL scale by dividing work across services.
Full Transcript
In GraphQL federation, a client sends a query to a gateway. The gateway breaks the query into smaller subqueries based on which service owns which part of the schema. It sends these subqueries to the respective services. Each service resolves its part and returns data. The gateway collects all responses and merges them into a single response for the client. This approach allows GraphQL to scale by distributing query resolution across multiple services, improving performance and maintainability.