Skip to the page

GraphQL in production · senior

Federation, and when GraphQL is the wrong choice

When many teams own one graph, a router composes subgraphs into a supergraph. For partner APIs, uploads and service-to-service calls, REST or gRPC is often a better fit.

The notes

What you must know

  • Options for many teams: one GraphQL server that calls the teams' services (simple, but one team becomes a bottleneck), a BFF per app, or federation.
  • Federation: each team runs a subgraph. A router composes them into one supergraph and builds a query plan. Entities are shared through a key, for example type Order @key(fields: "id").
  • One team can add fields to another team's entity through the same key. The router asks the owning subgraph for many objects in one _entities call.
  • Each subgraph's entity reference resolver must use a DataLoader, or that one call turns into N database queries.
  • Auth in federation: the router checks the token and passes identity to subgraphs, and each subgraph still enforces its own rules.
  • A good fit: many screens needing different shapes of related data, slow mobile networks, several client teams, a typed schema as the contract.
  • A poor fit: partner APIs (they want stable, cacheable endpoints, simple rate limits and curl), file uploads (use a presigned URL and a mutation that records the file), and service-to-service calls (gRPC or REST).

The red pen

Common traps: mistake → fix

  • Mistake: Federation removes the N+1 problem

    Fix: It can make it worse across subgraphs. Reference resolvers need loaders.

  • Mistake: GraphQL is always better than REST for every client

    Fix: Partners, uploads and simple CRUD services are often easier with REST and OpenAPI.

  • Mistake: A supergraph means one team owns everything

    Fix: Each team owns its subgraph and the entities it defines.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is federation and what problem does it solve?
  2. What is an entity and what does @key do?
  3. Where does the N+1 problem come back in a federated graph?
  4. Would you give partners a GraphQL API? Why or why not?
  5. Three teams own orders, delivery and catalogue. Design the graph and say who owns what.

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview