← Back to all projects

GRAPHQL FEDERATION MASTERY

As organizations grow, the API Monolith becomes a bottleneck. Multiple teams fighting over the same schema leads to deployment gridlock, fragile code, and developer burnout. GraphQL Federation was pioneered by Apollo to solve this exact problem: **distributed ownership with a unified interface.**

Learn GraphQL Federation: From Zero to Supergraph Architect

Goal: Deeply understand the principles of GraphQL Federation—not just as a tool, but as an architectural pattern for scaling distributed systems. You will learn how to decompose monoliths into autonomous subgraphs, unify them into a single “Supergraph,” and master the complex query planning, entity resolution, and performance optimizations required to run a production-grade federated API.


Why GraphQL Federation Matters

As organizations grow, the “API Monolith” becomes a bottleneck. Multiple teams fighting over the same schema leads to deployment gridlock, fragile code, and developer burnout. GraphQL Federation was pioneered by Apollo to solve this exact problem: distributed ownership with a unified interface.

The Evolution of the API

  1. The Monolith: One team, one schema, one server. Simple but doesn’t scale.
  2. Schema Stitching: Manually merging schemas. Fragile, requires the gateway to know too much about underlying logic.
  3. Federation: Subgraphs define their own entities and how they relate to others. The gateway (Router) automatically calculates the “Query Plan.”

Why it remains relevant

  • Microservices: It is the definitive way to provide a clean frontend experience over a complex microservice backend.
  • Developer Velocity: Teams can deploy subgraphs independently without breaking the Supergraph.
  • Performance: Modern Routers (like the Apollo Router in Rust) handle query orchestration with sub-millisecond overhead.

Core Concept Analysis

1. The Supergraph Architecture

In Federation, the “Gateway” or “Router” acts as the brain. It doesn’t contain business logic; it contains a Query Plan.

      [ Client ]
          |
          | (GraphQL Query)
          v
    +-----------+
    |  Router   | <--- (Supergraph Schema / Composition)
    +-----------+
          |
    +-----+-----+-----+
    |           |     |
    v           v     v
[User SG]   [Order SG] [Product SG]
 (Entity)    (Entity)   (Entity)

2. Entity Resolution (The Magic of @key)

The most critical concept in Federation is the Entity. An entity is an object type that can be uniquely identified across subgraphs.

Subgraph A (Users):
type User @key(fields: "id") {
  id: ID!
  username: String
}

Subgraph B (Reviews):
type Review {
  body: String
  author: User @provides(fields: "username") # Subgraph B "extends" User
}

extend type User @key(fields: "id") {
  id: ID! @external
  reviews: [Review]
}

3. The Query Planner

When a client asks for a user’s name AND their reviews, the Router performs a “Join” in the cloud:

  1. Step 1: Fetch id and username from User Subgraph.
  2. Step 2: Use the id from Step 1 to fetch reviews from the Review Subgraph.
  3. Step 3: Merge and return to client.

Project 1: The “Manual” Join (The Struggle Before Federation)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js (TypeScript)
  • Alternative Programming Languages: Go, Python, Rust
  • Coolness Level: Level 1: Pure Corporate Snoozefest
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 1: Beginner
  • Knowledge Area: API Gateway / Orchestration
  • Software or Tool: Express.js, Apollo Server (Non-federated)
  • Main Book: “Designing Data-Intensive Applications” by Martin Kleppmann

What you’ll build: A standard GraphQL API that acts as a gateway for two separate REST services (Users and Orders). You will manually write the resolvers that fetch from REST, map the data, and handle the “Join” logic.

Why it teaches Federation: You cannot appreciate Federation until you’ve manually solved the “N+1 problem” in a gateway. You’ll realize that as you add more services, your gateway code becomes a tangled mess of fetch calls and data transformations.

Core challenges you’ll face:

  • Resolver Orchestration → maps to understanding how data flows through a graph
  • N+1 Performance Issues → maps to the need for Dataloaders
  • Schema Duplication → maps to why type definitions shouldn’t be copied manually

Key Concepts:

  • The N+1 Problem: “Learning GraphQL” Ch. 5 - Eve Porcello
  • Dataloader Pattern: “GraphQL in Action” Ch. 6 - Samer Buna

Difficulty: Beginner Time estimate: Weekend Prerequisites: Basic GraphQL knowledge, ability to build a simple Express server.


Real World Outcome

You will have three running services:

  1. user-service (REST API)
  2. order-service (REST API)
  3. gateway (GraphQL API)

When you query the gateway, it will orchestrate calls to both.

Example Output:

# Query
query {
  user(id: "1") {
    name
    orders {
      total
    }
  }
}

# Gateway logs showing the inefficiency:
[Gateway] Fetching user 1...
[Gateway] Fetching orders for user 1...
[Gateway] Merging results...

The Core Question You’re Answering

“Why is it so hard to scale an API gateway manually as the number of microservices increases?”

Before you write any code, sit with this question. Every time you add a field to a REST service, you have to update the gateway. This is “tight coupling.”


Project 2: Your First Federated Supergraph (The Architecture)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js
  • Alternative Programming Languages: Rust, Go
  • Coolness Level: Level 2: Practical but Forgettable
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 1: Beginner
  • Knowledge Area: Microservices / Federation
  • Software or Tool: Apollo Router (Binary), Apollo Server (Subgraph library)
  • Main Book: “Building Microservices” by Sam Newman

What you’ll build: A minimal Supergraph with two subgraphs (Inventory and Marketing). No shared entities yet. You’ll use the official Apollo Router (written in Rust) to compose these two schemas into one.

Why it teaches Federation: This teaches you the separation of concerns. The Router is a standalone binary that doesn’t share code with the subgraphs. You’ll learn about the “Supergraph Schema” vs. “Subgraph Schema.”

Core challenges you’ll face:

  • Running the Router binary → maps to understanding the deployment model
  • Schema Composition → maps to using the rover CLI to build the supergraph
  • Network Latency → maps to observing the overhead of a multi-hop request

Key Concepts:

  • Separation of Concerns: “Building Microservices” Ch. 2 - Sam Newman
  • The Apollo Router: Official Apollo Docs - “Router Architecture”

Difficulty: Beginner Time estimate: Weekend Prerequisites: Project 1 completion, basic CLI usage.


Real World Outcome

You’ll see two separate GraphQL endpoints being transparently merged by a single Router.

Example Output:

$ rover dev --supergraph-config ./supergraph.yaml
# Rover starts composing the subgraphs...
# Router starts on http://localhost:4000

# Client Query
query {
  allInventoryItems { name } # Comes from Subgraph A
  currentPromotions { title } # Comes from Subgraph B
}

The Core Question You’re Answering

“How can the Router know about all fields without me writing a single resolver in the gateway?”

The answer lies in the Supergraph Schema—a special file that maps every field to a specific subgraph URL.


  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: TypeScript
  • Alternative Programming Languages: Java (Spring Boot), Python (Strawberry)
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Distributed Data Modeling
  • Software or Tool: Rover CLI, Apollo Federation 2
  • Main Book: “Designing Data-Intensive Applications” by Martin Kleppmann

What you’ll build: A “Users” subgraph and a “Posts” subgraph. You will turn the User type into an Entity. This allows the Posts subgraph to “contribute” a field called posts to the User type, even though the Posts subgraph doesn’t own the User.

Why it teaches Federation: This is the “Aha!” moment. You’ll understand how @key allows different services to collaborate on the same object type without knowing about each other’s internal logic.

Core challenges you’ll face:

  • Defining the primary key → maps to understanding identity across services
  • Writing the __resolveReference resolver → maps to how the router ‘finds’ an entity in a subgraph
  • Circular dependencies → maps to how the query planner avoids infinite loops

Key Concepts:

  • Entities: Apollo Federation Docs - “Entities”
  • Reference Resolvers: “Professional GraphQL” Ch. 8 - (Search for Apollo Reference Resolution)

Real World Outcome

A query for a User that includes their Posts, where the Router fetches the User from service A, and then “jumps” to service B to fetch the posts using the User’s ID.

Example Output:

# In the Browser (Studio/Sandbox)
query GetUserAndPosts {
  user(id: "u-1") {
    username      # From Users Subgraph
    posts {       # From Posts Subgraph!
      title
    }
  }
}

Project 5: The “Private” Graph (Custom Directives & Transformations)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: TypeScript / Rhai
  • Alternative Programming Languages: Go (Bravo), Rust
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Schema Governance & Security
  • Software or Tool: Apollo Router, Rhai Scripts
  • Main Book: “Code Complete” by Steve McConnell

What you’ll build: A custom directive called @private. Any field marked with this in a subgraph should be automatically stripped out during composition so it never appears in the public Supergraph schema.

Why it teaches Federation: It teaches you about the Composition Lifecycle. You’ll learn that the schema the client sees is not just a copy-paste of the subgraph schemas; it’s a transformed artifact. You’ll also touch on “Contract Variants.”

Core challenges you’ll face:

  • Defining custom directives in subgraphs → maps to understanding schema extension
  • Composition-time logic → maps to using Rover to apply custom transformations
  • Runtime validation → maps to ensuring the Router blocks access even if the schema is leaked

Key Concepts:

  • Schema Contracts: Apollo Docs - “Contracts”
  • Custom Directives: “Programming GraphQL” - (Search for Directive implementation)

Real World Outcome

You’ll have a field User.socialSecurityNumber in your subgraph that is totally invisible to the public API, even if a user tries to guess the field name.

Example Output:

# In Subgraph:
type User {
  id: ID!
  ssn: String @private
}

# After Composition (The Supergraph Schema):
type User {
  id: ID!
  # ssn is missing!
}

The Core Question You’re Answering

“How do we keep ‘internal-only’ data safe while using a unified API surface?”

The answer is Contracts. You learn that one Supergraph can have multiple “variants” (e.g., Public, Internal, Mobile).


Project 6: Secure Propagation (Auth in Federation)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js / Rust
  • Alternative Programming Languages: Go, Java
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Security & Identity
  • Software or Tool: JWT, Apollo Router (Headers configuration)
  • Main Book: “Advanced Programming in the UNIX Environment” (for the conceptual understanding of process isolation/security)

What you’ll build: A system where the Router validates a JWT from the client and then “injects” user information into the headers of every request it sends to subgraphs. You will also implement “Field-level Authorization” where only ADMIN can see certain fields across the entire Supergraph.

Why it teaches Federation: It teaches you about Trust Boundaries. In Federation, the Router is the gatekeeper. You’ll learn how to pass “Context” across network boundaries without re-validating the token in every single service.

Core challenges you’ll face:

  • Header Propagation → maps to configuring the Router to pass x-user-id
  • Context Injection → maps to making user data available in subgraph resolvers
  • Distributed Auth logic → maps to deciding where to check permissions (Router vs Subgraph)

Key Concepts:

  • Bearer Token Propagation: Official Apollo Docs - “Authentication and Authorization”
  • JWT Best Practices: RFC 7519

Real World Outcome

A query for mySensitiveData succeeds if the Authorization header has a valid token, and the Subgraph receives the x-user-id header automatically from the Router.

Example Output:

# Client Request
curl -H "Authorization: Bearer <token>" http://router/graphql ...

# Router Logs:
[Router] Authenticated user: "123"
[Router] Fetching from Inventory Subgraph with header "x-user-id: 123"

The Core Question You’re Answering

“In a federated world, who is responsible for checking if a user has permission to see a specific field?”

This forces you to grapple with Defense in Depth.


Project 7: The Federated N+1 (Advanced Dataloaders)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: TypeScript
  • Alternative Programming Languages: Go, Python
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Performance Optimization
  • Software or Tool: Dataloader library
  • Main Book: “High Performance Browser Networking” by Ilya Grigorik (for understanding the cost of RTT)

What you’ll build: A “Products” subgraph that has a Review entity. When a client asks for 50 products and their reviews, the Router will call the Review subgraph. You must implement a Dataloader inside the __resolveReference function to ensure that those 50 products are resolved in one batch database call, not 50.

Why it teaches Federation: It bridges the gap between basic GraphQL optimization and the distributed nature of Federation. You’ll realize that Federation actually increases the risk of N+1 problems if you aren’t careful.

Core challenges you’ll face:

  • Batching Entity References → maps to optimizing the internal _entities query
  • Cache Management → maps to ensuring the Dataloader cache is per-request
  • Query Plan analysis → maps to seeing the Router send a single large _entities request

Key Concepts:

  • The _entities resolver: Apollo Federation Specification - “Entity Resolution”
  • Batch Loading: “Grokking Algorithms” - (Conceptual understanding of efficiency)

Real World Outcome

You will query 100 items. Your Subgraph logs will show exactly one SQL SELECT ... WHERE id IN (...) instead of 100 individual queries.

Example Output:

# Subgraph Log:
[SQL] SELECT * FROM reviews WHERE product_id IN (1, 2, 3, ... 100);
# Total Queries: 1

The Core Question You’re Answering

“How does the Router communicate a list of entities to a subgraph, and how do we handle that list efficiently?”

You’ll discover the hidden _entities field that all federated subgraphs must implement.


Project 9: The Gatekeeper (Schema Checks & CI/CD)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Bash / YAML
  • Alternative Programming Languages: GitHub Actions, GitLab CI
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: DevOps / Governance
  • Software or Tool: Rover CLI, Apollo Studio (or a local schema check script)
  • Main Book: “Continuous Delivery” by Jez Humble

What you’ll build: A CI/CD pipeline that prevents “Breaking Changes.” If a developer tries to remove a field that is currently being used by the frontend, the CI should fail.

Why it teaches Federation: In Federation, a small change in one subgraph can break the entire Supergraph. This project teaches you Schema Governance. You’ll learn how to compare “Proposed” vs. “Running” schemas.

Core challenges you’ll face:

  • Defining a breaking change → maps to understanding semantic versioning for APIs
  • Integrating rover into a script → maps to automating schema registry updates
  • Composition failure handling → maps to what happens when subgraphs conflict

Key Concepts:

  • Schema Checks: Apollo Docs - “Schema Checks”
  • The Rover CLI: Official Apollo Documentation

Real World Outcome

You try to delete a field User.email in the Users subgraph. You run your script, and it yells at you because that field is required for the Supergraph composition or is being used by an active client.

Example Output:

$ rover subgraph check my-graph@prod --schema ./schema.graphql
FAIL: Breaking Changes Detected
- Field 'User.email' was removed.
- Reason: Field is currently used by 'Web-App' client.

The Core Question You’re Answering

“How do we ensure that independent teams don’t break each other’s work in a shared graph?”

You’ll discover the concept of a Schema Registry.


Project 10: Graceful Failure (Partial Results)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js
  • Alternative Programming Languages: Any (Simulating network failure)
  • Coolness Level: Level 2: Practical but Forgettable
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Resilience Engineering
  • Software or Tool: Apollo Router (Configuration)
  • Main Book: “Release It!” by Michael T. Nygard

What you’ll build: A Supergraph with three subgraphs. You will intentionally “crash” one subgraph (Reviews). You must configure the Router so that the client still gets the User and Product data, but with a null for reviews and a helpful error message.

Why it teaches Federation: It teaches you about Availability. In a distributed system, things WILL fail. You’ll learn how GraphQL handles errors naturally and how the Router manages timeouts and retries.

Core challenges you’ll face:

  • Configuring timeouts → maps to preventing cascading failures
  • Handling Nullability → maps to designing schemas for failure
  • Error Propagation → maps to mapping internal subgraph errors to client-friendly messages

Key Concepts:

  • Partial Success: “Learning GraphQL” Ch. 7 - (Search for Partial Results)
  • Circuit Breakers: “Release It!” - Michael T. Nygard

Real World Outcome

You query for a User + Reviews. The Reviews service is down. The query returns the User name perfectly, with a null for reviews and an “Errors” array explaining the outage.

Example Output:

{
  "data": {
    "user": {
      "name": "Alice",
      "reviews": null
    }
  },
  "errors": [
    { "message": "Reviews service is currently unavailable", "path": ["user", "reviews"] }
  ]
}

The Core Question You’re Answering

“In a Supergraph, is it better to fail the entire request or return whatever data we can find?”

This forces you to think about Schema Nullability—making fields nullable by default so they can fail gracefully.


Project 11: The Time Traveler (Federated Tracing)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: TypeScript
  • Alternative Programming Languages: Rust, Go
  • Coolness Level: Level 4: Hardcore Tech Flex
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 4: Expert
  • Knowledge Area: Observability
  • Software or Tool: OpenTelemetry, Apollo Inline Tracing
  • Main Book: “Distributed Systems” by Maarten van Steen (conceptual tracing)

What you’ll build: A setup where every query through the Router generates a detailed “Trace.” You’ll see a Gantt chart showing: 1. How long the Router took to plan. 2. How long Service A took. 3. How long Service B took. 4. The merge time.

Why it teaches Federation: It makes the Query Plan visible. You’ll see exactly where the bottlenecks are. You’ll learn the “Federated Tracing Specification”—a specific way subgraphs tell the Router about their performance.

Core challenges you’ll face:

  • Implementing the Tracing Spec → maps to adding headers to subgraph responses
  • Clock Skew → maps to handling time differences across servers
  • Tracing Propagation → maps to passing Trace IDs through the stack

Key Concepts:

  • Federated Tracing Spec: Apollo GitHub Repo - federated-tracing
  • OpenTelemetry: Official OTel Documentation

Real World Outcome

You’ll see a visual breakdown of your query. You’ll realize that the reason your API is “slow” is actually a 500ms delay in a specific subgraph, not the Router.

Example Output:

Total Time: 540ms
  [Router Planning]  ██ 10ms
  [Fetch: User]      ████████ 120ms
  [Fetch: Reviews]           ████████████████████ 400ms
  [Router Merge]     █ 5ms

The Core Question You’re Answering

“How do we debug a request that spans five different services across the network?”

You’ll learn that Trace Context is the only way to keep your sanity in microservices.


Project 13: The Live Graph (Subscription Federation)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js / Rust
  • Alternative Programming Languages: Go
  • Coolness Level: Level 5: Pure Magic
  • Business Potential: 4. The “Open Core” Infrastructure
  • Difficulty: Level 5: Master
  • Knowledge Area: Real-time Systems
  • Software or Tool: Apollo Router (Subscriptions support), Redis (for PubSub)
  • Main Book: “Designing Data-Intensive Applications” (Ch 11: Stream Processing)

What you’ll build: A system where a client can “Subscribe” to a specific entity. For example, subscribeToPrice(productId: "123"). The update will originate in the “Pricing” subgraph, travel through the Router, and hit the client over a WebSocket or SSE.

Why it teaches Federation: Subscriptions are the “Hard Mode” of Federation. It teaches you how the Router manages persistent connections and how it “fans out” events from subgraphs to multiple clients.

Core challenges you’ll face:

  • WebSocket Protocol Negotiation → maps to handling long-lived connections
  • Distributed PubSub → maps to using Redis to signal updates between subgraph instances
  • Query Planning for Subscriptions → maps to understanding that only the root can be a subscription

Key Concepts:

  • GraphQL Subscriptions: Apollo Docs - “Subscriptions in Federation”
  • HTTP/2 Server-Sent Events (SSE): MDN Web Docs

Real World Outcome

You open a terminal and run a script that updates a price in your database. Instantly, your GraphQL client (Sandbox/Studio) shows the new price without a page refresh.

Example Output:

# In Subgraph Logs:
[PubSub] Price updated for P-1: $99.99

# In Client Browser:
{
  "data": {
    "priceUpdated": {
      "newPrice": 99.99
    }
  }
}

The Core Question You’re Answering

“How does a stateless Router maintain the state required to push updates to thousands of clients simultaneously?”

You’ll discover the role of Subscription Gateways and how they differ from standard request/response.


Project 14: The Bridge (REST to Subgraph Wrapper)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: TypeScript
  • Alternative Programming Languages: Go, Python
  • Coolness Level: Level 2: Practical but Forgettable
  • Business Potential: 1. The “Resume Gold”
  • Difficulty: Level 2: Intermediate
  • Knowledge Area: Legacy Integration
  • Software or Tool: RESTDataSource (Apollo), Any Public REST API
  • Main Book: “Refactoring” by Martin Fowler

What you’ll build: You will take a legacy REST API (like the JSONPlaceholder or a Star Wars API) and build a “Subgraph Wrapper” around it. You’ll then link this legacy data to a modern “Users” subgraph using @key.

Why it teaches Federation: This is the most common real-world use case for Federation: Incremental Migration. It teaches you how to hide messy legacy endpoints behind a clean, federated interface.

Core challenges you’ll face:

  • Mapping REST params to GraphQL args → maps to schema design
  • Efficient fetching → maps to preventing the N+1 problem when the legacy API doesn’t support batching
  • Handling REST errors → maps to status code mapping (404 -> null, 500 -> error)

Key Concepts:

  • REST DataSource: Apollo Server Docs
  • The Strangler Fig Pattern: Martin Fowler’s Blog

Real World Outcome

You query your Supergraph for a User. The User’s name comes from your new Postgres DB, but their “Legacy Profile Data” is fetched on-the-fly from a 10-year-old REST API, and the client never knows the difference.

Example Output:

query {
  user(id: "1") {
    name           # Modern Subgraph
    legacyHistory { # REST Wrapper Subgraph
      action
      timestamp
    }
  }
}

The Core Question You’re Answering

“How can we adopt a modern architecture without rewriting every single legacy system first?”

The answer is the Adapter Pattern applied to the graph.


Project 15: Cross-Subgraph Mutations (The Atomic Struggle)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: Node.js
  • Alternative Programming Languages: Java, C#
  • Coolness Level: Level 3: Genuinely Clever
  • Business Potential: 3. The “Service & Support” Model
  • Difficulty: Level 4: Expert
  • Knowledge Area: Distributed Transactions
  • Software or Tool: Apollo Federation 2
  • Main Book: “Designing Data-Intensive Applications” (Ch 7: Transactions)

What you’ll build: A mutation checkout(orderId: ID!) that must update the “Inventory” subgraph (to deduct stock) AND the “Orders” subgraph (to mark as paid). You will explore why Federation doesn’t support atomic cross-subgraph mutations and how to implement the “Saga Pattern” to handle failures.

Why it teaches Federation: It highlights the Limitations of Federation. You’ll understand that Federation is a “Read-Optimized” pattern and that write operations require careful coordination in the business layer.

Core challenges you’ll face:

  • The “Single Subgraph Mutation” rule → maps to understanding why mutations aren’t auto-merged
  • Compensating Transactions → maps to what to do if the second service fails
  • Eventual Consistency → maps to handling the lag between service updates

Key Concepts:

  • The Saga Pattern: Microservices.io
  • Distributed Transactions: “Designing Data-Intensive Applications”

Real World Outcome

You execute a mutation. Service A succeeds. You simulate a failure in Service B. Your code must automatically trigger a “Rollback” or “Compensation” in Service A to keep the system consistent.

Example Output:

[Mutation] Starting Checkout...
[Inventory] Reserved Item #101
[Orders] FAILED (Database Timeout)
[Inventory] ROLLBACK: Un-reserving Item #101
[Client] Error: Checkout failed, no charges were made.

The Core Question You’re Answering

“Why shouldn’t the Router be responsible for distributed transactions?”

You’ll learn that the Router is an orchestrator of data, not a coordinator of state.


Project 16: The Consumer’s View (Micro-frontend Integration)

  • File: GRAPHQL_FEDERATION_MASTERY.md
  • Main Programming Language: React / TypeScript
  • Alternative Programming Languages: Vue, Svelte
  • Coolness Level: Level 5: Pure Magic
  • Business Potential: 5. The “Industry Disruptor”
  • Difficulty: Level 3: Advanced
  • Knowledge Area: Frontend Architecture
  • Software or Tool: Apollo Client, Webpack Module Federation
  • Main Book: “Micro Frontends in Action” by Michael Geers

What you’ll build: A dashboard where the “Header” MFE, “Content” MFE, and “Sidebar” MFE are all separate React apps. Each one makes its own GraphQL queries to the SAME Federated Router. You’ll implement “Query Deduplication” and “Normalized Caching” to ensure that if two MFEs ask for the same User, only one request goes to the Router.

Why it teaches Federation: It shows the Frontend Value Prop. You’ll see how Federation allows frontend teams to be as decoupled as backend teams.

Core challenges you’ll face:

  • Shared Apollo Cache → maps to preventing MFEs from overwriting each other’s data
  • Query Fragment Colocation → maps to defining data needs at the component level
  • Loading State Coordination → maps to preventing layout shift when different subgraphs return at different times

Key Concepts:

  • Normalized Cache: Apollo Client Docs
  • Module Federation: Webpack 5 Documentation

Project Comparison Table

Project Difficulty Time Depth of Understanding Fun Factor
1. Manual Join Level 1 Weekend High (Foundational) ★★☆☆☆
2. First Supergraph Level 1 Weekend Medium ★★★☆☆
3. Entity Link Level 2 1 Week High (Architecture) ★★★★☆
4. Calculated Field Level 2 1 Week High (Query Planning) ★★★☆☆
5. Private Graph Level 3 1 Week Medium (Governance) ★★★☆☆
6. Secure Propagation Level 3 1 Week High (Security) ★★★★☆
7. Federated N+1 Level 3 1 Week High (Performance) ★★★☆☆
8. Rhai Scripting Level 4 2 Weeks High (Systems) ★★★★★
9. Schema Checks Level 2 1 Week Medium (DevOps) ★★☆☆☆
10. Graceful Failure Level 3 1 Week High (Resilience) ★★★★☆
11. Federated Tracing Level 4 2 Weeks High (Observability) ★★★★☆
12. Versioning Level 2 Weekend Medium ★★☆☆☆
13. Subscriptions Level 5 1 Month Very High (Real-time) ★★★★★
14. REST Wrapper Level 2 1 Week High (Pragmatic) ★★★☆☆
15. Cross-SG Mutations Level 4 2 Weeks High (Dist. Systems) ★★★★☆
16. MFE Integration Level 3 2 Weeks High (Frontend) ★★★★★

Recommendation

If you are a Backend Engineer: Start with Project 1 to understand the pain, then jump to Project 3 (Entities) and Project 7 (Performance). These are the “meat” of the federation role.

If you are a Frontend Engineer: Focus on Project 2, Project 12 (Versioning), and Project 16 (MFEs). This will teach you how to consume a federated graph effectively.

If you are an Architect: You must complete Project 8 (Rhai), Project 9 (Checks), and Project 15 (Mutations) to understand the long-term trade-offs and safety mechanisms.


Final Overall Project: The “Global Unified Platform”

What you’ll build: A complete, production-ready Supergraph for a fictional global e-commerce giant (“AetherCart”).

Components:

  1. Core Subgraphs: Users, Products, Orders, Reviews, Inventory, Shipping, and Marketing.
  2. Infrastructure:
    • Apollo Router (Rust) with custom Rhai logic for A/B testing header injection.
    • A local Schema Registry (using Rover) integrated into a GitHub/GitLab CI pipeline.
    • Redis-backed Subscriptions for live stock updates.
    • OpenTelemetry integration for end-to-end tracing.
  3. Complex Logic:
    • Entities linked across at least 4 subgraphs.
    • @requires and @provides usage for calculating “Loyalty Points” across Orders and Users.
    • A legacy “Warehouse” REST API wrapped as a subgraph.
  4. Resilience:
    • Circuit breakers and timeouts configured for the Shipping subgraph.
    • Proper @deprecated tags for a legacy v1 field set.
  5. Frontend:
    • A React dashboard using Apollo Client that demonstrates fragment colocation.

The Ultimate Outcome: A portfolio piece that demonstrates you can design, deploy, and maintain a distributed API architecture that can scale to hundreds of microservices.


Summary

This learning path covers GraphQL Federation through 16 hands-on projects. Here’s the complete list:

# Project Name Main Language Difficulty Time Estimate
1 Manual Join Node.js Beginner Weekend
2 First Supergraph Node.js Beginner Weekend
3 Entity Link TypeScript Intermediate 1 Week
4 Calculated Field Node.js Intermediate 1 Week
5 Private Graph TypeScript Advanced 1 Week
6 Secure Propagation Node.js/Rust Advanced 1 Week
7 Federated N+1 TypeScript Advanced 1 Week
8 Rhai Scripting Rhai Expert 2 Weeks
9 Schema Checks Bash/YAML Intermediate 1 Week
10 Graceful Failure Node.js Advanced 1 Week
11 Federated Tracing TypeScript Expert 2 Weeks
12 Versioning GraphQL SDL Intermediate Weekend
13 Subscriptions Node.js/Rust Master 1 Month
14 REST Wrapper TypeScript Intermediate 1 Week
15 Cross-SG Mutations Node.js Expert 2 Weeks
16 MFE Integration React/TS Advanced 2 Weeks

For beginners: Start with projects #1, #2, #3, #12 For intermediate: Jump to projects #4, #7, #9, #14 For advanced: Focus on projects #8, #11, #13, #15

Expected Outcomes

After completing these projects, you will:

  • Master the Federation 2.0 Specification and its core directives.
  • Understand how to architect Entities for distributed data ownership.
  • Be able to configure and extend the high-performance Apollo Router (Rust).
  • Implement robust CI/CD for schemas, preventing breaking changes.
  • Master distributed observability, security, and performance optimization.

You’ll have built 16 working projects that demonstrate deep understanding of GraphQL Federation from first principles.