GraphQL Federation: connect subgraphs behind one API
GraphQL Federation combines GraphQL schemas owned by multiple services into one coherent API for clients. Each service contributes a subgraph; composition combines the subgraph schemas into a supergraph schema. A router uses its metadata to send work to the relevant subgraphs and combine their results. Federation is not automatically worthwhile just because services are split up: first compare independent team deployment with the costs of composition, routing, and schema operations.
GraphQL Federation combines GraphQL schemas owned by multiple services into one coherent API for clients. Each service contributes a subgraph; composition combines the subgraph schemas into a supergraph schema. A router uses its metadata to send work to the relevant subgraphs and combine their results. Federation is not automatically worthwhile just because services are split up: first compare independent team deployment with the costs of composition, routing, and schema operations.
This article uses Apollo Federation terminology and examples, specifically Federation 2 syntax. It does not assume that other federation implementations or a future standard behave identically.
Components and request flow
**Subgraph:** A service that provides a GraphQL schema and resolvers for one domain. A product service might own product fields and lookups; a reviews service might own reviews and their relationship to products.
**Composition:** Checks and connects subgraph schemas to produce a supergraph schema. It is more than concatenating type definitions: it checks field ownership and resolvability, type compatibility, and creates routing metadata.
**Router:** The single client entry point. It plans a request from supergraph metadata, calls the required subgraphs, and combines their responses.
**Supergraph and API schema:** The supergraph includes federation-specific information about subgraphs and routing. The API schema exposed to clients can hide those internal implementation details.
The client sends one GraphQL operation to the router. For example, it can request a product and the names of its review authors. The router can fetch the product from the subgraph that owns its fields, then call another subgraph to resolve author data using entity references and selected fields. Actual network calls and performance depend on the query plan, servers, data, and deployment. One GraphQL request does not mean one backend call.
Entities connect types across services
When subgraphs contribute different fields for the same concept, they need a shared identity rule to connect the object. In Apollo Federation 2, @key identifies an entity by a set of fields that other subgraphs can reference. For example, if the products subgraph owns Product names and prices and the reviews subgraph provides reviews, a shared key can connect the Product entity.
type Product @key(fields: "id") {
id: ID!
name: String!
}The reviews subgraph references that entity with compatible Federation syntax and contributes fields it resolves, such as reviews. The entity reference resolver and directive definitions must match the chosen subgraph library and Federation version. Directives such as @shareable, @external, @requires, and @provides express field ownership and dependencies on values from other subgraphs; careless use can create ambiguous ownership or composition errors.
Composition validates the combined schema contract
Subgraph schemas can be valid individually and still conflict when composed. For example, when multiple subgraphs define the same object field, Federation rules require compatible resolvability and types. Differences in input fields or arguments can also change the contract expressible in the supergraph. A composition failure can catch an invalid combined API contract before deployment.
Apollo documents GraphOS automatic composition when subgraph schemas are published, as well as manual composition with Rover CLI. These are product options, not universal operational requirements for every federation implementation. Whatever tool you use, automate composition checks before deploying a changed subgraph, and make sure the responsible team can fix failures.
When Federation fits—and its costs
Federation can help when multiple domain teams own and deploy their services independently while clients still need one unified graph. Subgraphs can use different technology stacks if they follow compatible federation rules. Domain teams own their fields and resolvers; a central router owns the client entry point and request orchestration.
The trade-off is additional operations work: composition and schema-change management, entity keys and data contracts across subgraphs, router availability/capacity/security, network latency, distributed tracing, partial failures, and ownership between teams. Combining fields from several services in one operation can add backend calls and failure paths. Federation does not automatically optimize backend queries or replace a data platform.
If there are few service or team boundaries and one GraphQL server is sufficient, a monolithic schema may be simpler. The official GraphQL guidance notes that Federation needs substantial infrastructure and central support; an organization can start with a monolith and move later when the need is clear.
Adopt it in stages
**State the organizational problem.** Record the current bottleneck: independent deployments, domain ownership, or one client API. A large number of services alone does not establish a need for Federation.
**Define boundaries.** Split subgraphs around domain ownership and change responsibility, rather than mechanically matching database or team names.
**Model one small flow.** Choose a representative operation that crosses two subgraphs. Check that the `@key` identifier is stable and can be resolved consistently by both services.
**Add composition checks and change rules first.** Check type compatibility, duplicate fields, entity references, and API-schema exposure; prevent deployment when checks fail.
**Measure request and operational behavior.** Observe the query plan, subgraph calls, latency, errors, and resource use for a representative operation. Do not assume one client request is faster without measurement.
**Design recovery and security.** Define router authentication, trust between subgraphs, call limits, timeouts, partial-failure handling, observability, and rollback ownership.
Readiness checklist
Are service/team boundaries and field owners clear?
Is there a real use case for one API for clients?
Are entity keys stable and interpreted consistently across subgraphs?
Can composition be checked automatically before deployment and rolled back?
Is a team accountable for the router and distributed latency, errors, and access control?
Could a simpler monolithic schema solve the same organizational problem?
Sources
[Official GraphQL Federation guide](https://graphql.org/learn/federation/)
[Introduction to Apollo Federation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/federation)
[Apollo guide to subgraph, supergraph, and API schemas](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/schema-types)
[Apollo schema composition documentation](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/composition)
[Apollo Federation composition rules](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/composition-rules)
[Apollo Federation directives reference](https://www.apollographql.com/docs/graphos/schema-design/federated-schemas/reference/directives)