GraphQL Federation Across Teams: What It Actually Solves and When It's a Layer Nobody Asked For
When several backend teams each own their own service, and the frontend needs to combine data from a few of them on a single screen, the same question keeps coming up: who stitches that data together, and where? Apollo Federation offers a concrete answer: each team publishes a GraphQL subgraph with its own schema, and a gateway composes all of those subgraphs into a single graph that the client queries as if it were one service. The demo always sells it, because the documentation's example is built to sell it. What you have to decide before adopting it isn't whether the technology works — it works — but whether the problem it solves is the one you actually have.
The simpler pattern already covers most cases
Before reaching for federation, the usual pattern for this problem is a BFF (backend for frontend): a service that calls whatever backends it needs, assembles the response in the shape that specific frontend requires, and exposes it through a single endpoint. A frontend team — or a platform team — owns that BFF, decides what it combines and how, and when a backend changes its contract, the BFF is the only place that needs adjusting.
// bff/resolvers/fullProfile.js
async function getFullProfile(userId) {
const [user, orders, preferences] = await Promise.all([
usersClient.get(userId),
ordersClient.listByUser(userId),
preferencesClient.get(userId),
]);
return {
...user,
recentOrders: orders.slice(0, 5),
preferences,
};
}
This covers perfectly well the case of one frontend, or a handful of them, pulling data from several backends where a single team can reasonably own the combination logic. The operational cost is running one more service, not coordinating a composed schema across teams that don't report to the same person.
What federation solves that a BFF doesn't
The problem federation specifically targets is different: it isn't "combine data from several backends," it's "let each team own its slice of the schema without a central team having to maintain the mapping for everyone else's." The difference shows up when domain types reference each other and that cross-reference changes often.
Say the catalog team owns the Product type, and the inventory team needs to add an availability field without touching the catalog repository or waiting for that team to ship a change:
# catalog-subgraph/schema.graphql
type Product @key(fields: "id") {
id: ID!
name: String!
price: Int!
}
# inventory-subgraph/schema.graphql
extend type Product @key(fields: "id") {
id: ID! @external
availability: Int!
}
The @key directive tells the gateway how to recognize the same Product entity when it shows up in two different subgraphs, and @external marks that id isn't resolved here but comes from elsewhere. The reference resolver in the inventory subgraph only needs the id:
const resolvers = {
Product: {
__resolveReference(product) {
return db.inventory.findByProductId(product.id);
},
},
};
With this, the inventory team deploys its subgraph whenever it wants, with no joint deploy coordination with catalog, and the gateway recomposes the full graph from the published schemas. That deploy independence between teams, while keeping a single consistent graph on the client side, is what a centralized BFF can't give you: in a BFF, any new field that crosses domains has to be written by whichever team owns the BFF, whether or not they know that domain in any depth.
The cost that doesn't show up on day one
What the docs don't put in the same paragraph as the demo is everything you now have to operate to keep that composition safe in production. The gateway needs a composition step that validates, on every change to any subgraph, that the resulting composed schema is still valid: a field one subgraph renames without coordination can break a query another team had working, and the error shows up at the gateway, not in the subgraph that caused it. That forces a CI pipeline that runs composition and contract checks before every deploy of every subgraph, not just the gateway's.
A performance problem also shows up that doesn't exist in a single service: a query that crosses three subgraphs produces an execution plan with chained calls between them, and if a reference resolver doesn't batch through a dataloader, the gateway ends up making one call per entity instead of one per batch — the same N+1 pattern you already solve inside a single service, except now it crosses the network between subgraphs.
// bad: one network call per product
const resolvers = {
Product: {
__resolveReference(product) {
return db.inventory.findByProductId(product.id);
},
},
};
// better: batched with dataloader
const inventoryLoader = new DataLoader(async (ids) => {
const rows = await db.inventory.findByProductIds(ids);
const byId = new Map(rows.map((r) => [r.productId, r]));
return ids.map((id) => byId.get(id));
});
const resolvers = {
Product: {
__resolveReference(product) {
return inventoryLoader.load(product.id);
},
},
};
Neither of these costs is exclusive to federation — contract CI and batched dataloaders are needed in any distributed architecture — but federation makes them mandatory starting from the first subgraph with a cross-reference, not optional the way they can be in a small BFF.
When it's justified, and when it isn't
Federation is justified when several teams, each owning a distinct domain, need their entities to reference each other within the same graph, and that need to cross-reference keeps growing instead of staying fixed to a handful of fields known upfront. It's also justified when there's more than one consumer of the graph — more than one frontend, or a frontend plus internal integrations — because that's where the cost of maintaining a BFF per consumer starts to outweigh the cost of maintaining the composition.
It isn't justified when there's a single backend team, or a few teams that coordinate their deploys often anyway, or a single frontend consuming the data. In that scenario, a REST BFF or a single GraphQL resolver that calls the backends internally solves the same problem with one less operational piece: no separate gateway, no composition step, no subgraph having to version its schema for consumers that don't exist yet.
What didn't work the first time
The first attempt we made at splitting an existing schema into subgraphs was dividing it by technical layer: one subgraph for queries, another for mutations, on the theory that each team would own the half it touched most. It didn't work, because domain types ended up split with no real ownership criterion behind it: the Order type was referenced from both subgraphs, and neither team could clearly claim ownership of it, which turned any change to Order into a two-team negotiation instead of a one-team decision. What worked was splitting the schema by business domain — catalog, inventory, orders — so each subgraph matched an ownership boundary that already existed on the team, rather than a technical split between reads and writes.
What we check before adopting federation on a new project
Before proposing federation instead of a BFF, we confirm there's more than one backend team with genuinely distinct domains, and that their types reference each other in a way that's going to keep growing, not a one-off reference that a single computed field can resolve once and for all. We check that there's more than one real consumer of the composed graph, because a federation gateway for a single frontend is the same complexity without the benefit that justifies it. And if we do move forward, we treat the CI composition pipeline as non-negotiable from the first subgraph on, not as something added "when it's needed" — because by the time it's needed, there's already been an incident that made it obvious.