Skip to main content
← Back to articles

GraphQL Federation in Microservice Landscapes

When subgraph ownership, schema governance, and gateway caching justify GraphQL at the edge.

Nestlancer Editorial

Share

Federation lets each team own a subgraph while clients query one graph—but operational cost is real. Adopt federation when client flexibility justifies schema governance overhead.

When federation fits

  • Mobile and web clients need different field sets on shared entities
  • Multiple teams publish types around User, Order, Project without monolith coordination
  • BFF proliferation is already unmanageable

Skip federation when simple REST aggregation at the gateway covers 90% of queries.

Subgraph ownership rules

  • Each subgraph maps to one team's deploy cadence
  • Breaking schema changes require consumer contract tests
  • @key directives and entity resolution must be integration-tested
  • Version deprecation with sunset dates in the schema registry

Performance traps

TrapFix
N+1 entity resolutionDataLoader per request
Uncached hot pathsGateway-level persisted queries
Oversized introspectionDisable in production

Gateway caching

Public fields (Product.name) cache aggressively; personalized fields (Cart.items) bypass cache. Document cache keys in subgraph README files.

GraphQL federation trades REST simplicity for client ergonomics—invest in schema review boards before production.

Comments

Loading comments…

Related posts