Skip to content

Lesson 7 of 9 · 27m

Federation in Practice: One Graph, Many Teams

What Apollo Federation actually solves, how entities and keys work, where ownership boundaries belong, and why federation magnifies both good and bad schema design.

Federation is an organizational scaling tool wearing technical clothes. It lets multiple teams own subgraphs behind one externally coherent graph. It does not make incoherent domains coherent. If two teams disagree about what a customer is, a router will faithfully distribute that confusion to every client at wire speed.

The shape of a federated graph

Instead of one monolithic schema service, teams publish subgraphs. A router or gateway composes them into a supergraph and plans each operation across services:

client
  |
router
  |-- accounts subgraph
  |-- billing subgraph
  |-- inventory subgraph

A typical entity looks like this in the accounts subgraph:

type Member @key(fields: "id") {
  id: ID!
  displayName: String!
}

The billing subgraph can extend it:

extend type Member @key(fields: "id") {
  id: ID! @external
  delinquentInvoices(first: Int, after: String): InvoiceConnection!
}

Now a client can ask one question across ownership boundaries:

query MemberBilling($id: ID!) {
  member(id: $id) {
    displayName
    delinquentInvoices(first: 5) {
      edges { node { amountDue status } }
    }
  }
}

The router resolves Member.id in accounts, then uses that key to fetch invoice fields from billing.

Keys are integration contracts

Choose stable, immutable keys. If a key can change, representation caching and cross-subgraph references break in subtle ways. A synthetic opaque ID is usually better than an email address, slug, or tenant-scoped sequence. Multiple keys are possible, but every extra key is another coupling surface.

Ownership boundaries follow domain ownership

The team that owns account lifecycle should own Member identity fields. The billing team should own invoice and plan fields. Avoid two subgraphs writing competing truth for the same conceptual field. Composition can merge types mechanically; it cannot reconcile semantic ownership.

A useful test: if a field requires a meeting with another team before every change, it is in the wrong subgraph.

Federation changes failure modes

A monolith fails in one process. A federated graph fails partially by subgraph. The router must distinguish composition failures, subgraph unavailability, entity resolution failures, and slow query plans. Clients need nullable fields where partial data is acceptable. Operators need subgraph health and query-plan visibility.

Common operational controls:

  • Pin and validate composed schemas before deploy.
  • Roll out subgraph schema changes before fields depending on them are exposed.
  • Time out entity resolution separately from root operations.
  • Canary router configuration independently of subgraph deployments.

Do not distribute a monolith accidentally

If every query touches every subgraph, you did not build federation; you built a monolith with network latency. Watch entity hops in query plans. Sometimes denormalizing a display field into the owning context is better than four service calls to render a table row.

Field notes

  • Federation is most valuable when teams can deploy schemas independently without negotiation.
  • Composition errors are build-time failures, not runtime surprises — run them in CI.
  • Entity keys should be stable across migrations, renames, and tenant moves.
  • A subgraph outage should degrade only the fields it owns when the schema permits it.
  • Keep the router thin; business logic inside routing config becomes invisible coupling.

Was this lesson helpful?

Sign in to rate