GraphQL Federation is an architectural pattern that enables a single, unified GraphQL API (a supergraph) to be composed from multiple, independently managed GraphQL services (called subgraphs). This approach allows different teams to own distinct domains—such as a product catalog, user management, or a knowledge graph backend—while exposing a cohesive data graph to clients. A gateway or router intelligently decomposes incoming queries, routes fragments to the correct subgraphs, and merges the results, abstracting the underlying distributed system complexity from the consumer.
Glossary
GraphQL Federation

What is GraphQL Federation?
GraphQL Federation is an architectural pattern for composing a single, unified GraphQL API (the supergraph) from multiple, independently managed GraphQL services (subgraphs).
This pattern is a cornerstone of Knowledge Graph as a Service architectures, where a federated supergraph can seamlessly integrate a deterministic knowledge graph subgraph with other business services. It provides a unified query interface across a microservices landscape, enabling efficient data fetching without the over-fetching or under-fetching typical of REST. Key implementations include Apollo Federation and the emerging GraphQL Federation 2 specification, which standardize the composition and entity resolution logic between subgraphs.
Core Architectural Components
GraphQL Federation is an architectural pattern that enables a single, unified GraphQL API (the supergraph) to be composed from multiple, independently deployed GraphQL services (subgraphs), including knowledge graph backends.
Supergraph Router (Gateway)
The supergraph router (or gateway) is the central component that receives client queries, intelligently routes them to the correct subgraph services, and composes the results. It uses a supergraph schema, a composed schema generated from all subgraph schemas, to understand the complete data graph and execute query planning. This architecture allows clients to query data from multiple services as if they were a single source, abstracting the underlying microservices complexity.
Subgraph Service
A subgraph is an independently deployable GraphQL service that owns a specific domain of the overall data graph (e.g., a Product service, a User service, or a Knowledge Graph service). Each subgraph:
- Defines its own GraphQL schema with types and fields it is responsible for.
- Implements resolvers to fetch data from its backend (e.g., a database, REST API, or triplestore).
- Can be developed, deployed, and scaled by separate teams. In a federated architecture, a subgraph can extend types defined by other subgraphs, enabling a unified type system across services.
Entity & @key Directive
The entity is the core abstraction of federation. An entity is a GraphQL object type that can be resolved across multiple subgraphs. The @key directive defines the primary key fields (e.g., id, sku) that uniquely identify an instance of that entity. For example:
graphqltype Product @key(fields: "id") { id: ID! name: String! description: String }
This allows the router to fetch a Product by its id from the subgraph that defines it, and then reference that entity to fetch extended fields (like inventory or reviews) from other subgraphs.
Query Planning & Execution
When a client query arrives, the router performs query planning. It:
- Parses the query against the supergraph schema.
- Builds a query plan that breaks the query into smaller operations (query fragments) that can be executed by individual subgraphs.
- Sequences these operations, often requiring multiple round trips where the result from one subgraph provides keys to fetch related data from another (entity reference resolution).
- Composes the results from all subgraphs into a single response for the client. This process is transparent to the client, which sees only the final, unified result.
Schema Composition & Registry
Schema composition is the automated process of merging all subgraph schemas into a single, validated supergraph schema. This is typically managed by a schema registry service. The process involves:
- Subgraphs publishing their schemas (with federation directives) to the registry.
- The registry composing them, checking for type conflicts and consistency.
- The router fetching the latest composed supergraph schema to enable accurate query planning. This centralized schema management ensures a contract between all services and the gateway, enabling safe, incremental evolution of the federated graph.
Knowledge Graph as a Subgraph
In an enterprise context, a Knowledge Graph backend can be integrated as a specialized subgraph. This subgraph:
- Exposes entity-centric queries (e.g., finding all suppliers for a product) and graph pattern queries (e.g., traversing relationships).
- Uses its resolvers to execute semantic queries (e.g., SPARQL or Cypher) against a triplestore or property graph database.
- Can extend core business entities (like
ProductorCustomer) with rich, inferred relationships and attributes derived from the knowledge graph. This pattern provides a unified query interface, allowing clients to seamlessly combine operational data from microservices with contextual, relationship-rich data from the knowledge graph.
How GraphQL Federation Works
GraphQL Federation is an architectural pattern for composing a single, unified GraphQL API from multiple independent backend services, including knowledge graphs and microservices.
GraphQL Federation is an architectural pattern that enables a single, unified GraphQL API (the supergraph) to be composed from multiple independent GraphQL services (subgraphs). Each subgraph, which can be a microservice, a knowledge graph backend, or a legacy system, owns a distinct portion of the overall data schema. A federation gateway (or router) sits in front of these subgraphs, intelligently decomposing incoming client queries, routing fragments to the correct services, and stitching the results into a single coherent response. This allows different teams to develop and deploy their domain services autonomously while presenting a cohesive data graph to consumers.
The pattern relies on a federation specification that defines how subgraphs declare their capabilities and how entities—objects with a unique key that can be extended across services—are resolved. When a query references an entity field owned by another subgraph, the gateway automatically generates a representation and performs an entity fetch to retrieve the necessary data, a process known as query planning. This architecture is fundamental for integrating knowledge graph as a service platforms into a broader microservices landscape, providing a unified semantic layer over disparate data sources without centralizing ownership.
Federation vs. Alternative GraphQL Patterns
A feature comparison of GraphQL Federation against other common patterns for composing and scaling GraphQL APIs in a microservices landscape, particularly when integrating knowledge graph backends.
| Architectural Feature / Metric | GraphQL Federation | Schema Stitching | Monolithic GraphQL API | API Gateway (REST/BFF) |
|---|---|---|---|---|
Core Architecture | Composed supergraph from distributed subgraphs | Runtime schema merging from remote schemas | Single, centralized schema and resolver implementation | Request routing & aggregation layer over REST/gRPC backends |
Service Ownership & Decoupling | Teams own and deploy their subgraph independently | Teams own schemas, but a central service performs stitching | All teams contribute to a single, shared codebase | Teams own backend services; gateway is a shared infrastructure component |
Schema Definition & Evolution | Subgraph schemas are composed declaratively; contracts enable safe evolution | Schema extensions and merges are programmed; evolution risks merge conflicts | All schema changes are coordinated and released monolithically | No unified schema; relies on backend service contracts (OpenAPI, Protobuf) |
Unified Query Execution | Query planner decomposes queries and orchestrates execution across subgraphs | Query executor delegates to remote schemas, often with nested resolution | All resolvers execute within the same runtime context | Gateway performs request fan-out and response composition; no query language |
Entity Resolution & Joins | Native support via | Requires manual resolver delegation and context passing between services | Trivial, as all data access is within the same service | Requires custom orchestration logic in the gateway or client-side joins |
Performance Optimization | Query planning minimizes subgraph round trips; supports subgraph-level caching | N+1 query risk if not carefully optimized; caching is service-specific | Full control over data fetching (e.g., DataLoader) within a single process | Dependent on backend service performance; caching strategies are generic (HTTP) |
Tooling & Ecosystem | Mature, vendor-supported tools (Apollo Router, Apollo Studio) | Library-based (e.g., GraphQL Tools); requires more custom integration | Extensive generic GraphQL server tooling | Mature API gateway ecosystem (Kong, Apigee, Envoy) but GraphQL-agnostic |
Best Suited For | Large-scale microservices requiring a unified, evolvable graph API | Moderate complexity with a few services, or incremental adoption of GraphQL | Small teams or applications with a single, cohesive data domain | Organizations with established REST/gRPC services needing a unified entry point |
Enterprise Use Cases for Federation
GraphQL Federation enables a unified data graph across distributed services. These are its primary applications in enterprise microservices and knowledge graph architectures.
Unified API for Microservices
Federation creates a single, cohesive GraphQL schema from multiple independent backend services (subgraphs). This allows frontend clients to query data across product catalogs, user profiles, and order systems in one request, eliminating the need for complex client-side aggregation and reducing network chatter.
- Declarative Composition: Each team owns a subgraph defining its domain (e.g.,
InventoryService,PaymentService). - Schema Stitching: A federated gateway (e.g., Apollo Router) automatically merges these into a unified supergraph.
- Example: A dashboard fetches a user's recent orders, the items in each order, and real-time inventory status for those items via one query to the federated endpoint.
Integrating Legacy & Modern Systems
Federation acts as an adapter layer for gradually modernizing monolithic applications. Legacy REST APIs or SOAP services can be wrapped as individual subgraphs, allowing them to participate in the modern GraphQL ecosystem without a full rewrite.
- Incremental Migration: New microservices are built as native subgraphs while legacy systems are wrapped, enabling a phased transition.
- Data Transformation: The subgraph for a legacy system handles the translation between its proprietary format and the federated graph's types.
- Use Case: Exposing data from a mainframe-based CRM alongside a modern SaaS marketing automation platform through a single GraphQL interface.
Knowledge Graph as a Federated Service
A central enterprise knowledge graph can be exposed as a federated subgraph, providing deterministic, entity-centric data to other services. This turns the knowledge graph into a reusable semantic layer for facts, relationships, and business logic.
- Entity Resolution & Context: Other services can extend core entities (e.g., a
CustomerorProductdefined in the KG) with their own domain-specific fields. - Cross-Referencing: A
Productsubgraph can reference authoritative data (supplier, compliance info) from the knowledge graph subgraph. - Example: An e-commerce service federates with a knowledge graph subgraph to enrich product listings with unified taxonomy categories and sustainability attributes.
Domain-Driven Design Alignment
Federation provides a technical implementation pattern that maps directly to bounded contexts in Domain-Driven Design (DDD). Each subgraph represents a clear business domain, enforcing separation of concerns and autonomy for development teams.
- Ownership Boundaries: The team owning the
Shippingdomain has full control over its subgraph's schema, resolvers, and database. - Shared Kernel: Common entities (like
User) can be partially defined by one subgraph and extended by others, avoiding a single, monolithic definition. - Benefit: Prevents the "big ball of mud" schema and aligns software architecture with business organization.
Performance with Query Planning
A federated gateway performs query planning to decompose a single client query into efficient sub-queries, which are executed in parallel against the relevant subgraphs. This optimizes data fetching and minimizes latency.
- Intelligent Routing: The gateway analyzes the query, determines which subgraphs hold the required fields, and sends optimized requests.
- Batching & Caching: Requests to the same subgraph can be batched, and subgraph-level caching strategies can be implemented.
- Example: A query for a user's name (from
UserService) and their last invoice amount (fromBillingService) is split and executed concurrently, not sequentially.
Governance & Decentralized Schema Evolution
Federation supports a decentralized but governed approach to schema management. Teams can evolve their subgraphs independently while a central contract (the supergraph) provides coordination and prevents breaking changes.
- Schema Checks: CI/CD pipelines can run composition checks to validate that a subgraph update integrates safely with the supergraph.
- Contract First: The federated graph's unified schema acts as a published contract for all clients.
- Tooling: Platforms like Apollo Studio provide visibility into schema changes, query usage, and performance across all federated services.
Frequently Asked Questions
GraphQL Federation is an architectural pattern for composing a unified GraphQL API from multiple independent services, including knowledge graphs. This section addresses common technical questions about its implementation, benefits, and role in enterprise data architectures.
GraphQL Federation is an architectural pattern and set of specifications that enable multiple GraphQL services (called subgraphs) to be composed into a single, unified GraphQL API (the supergraph) by a gateway/router. It allows an organization to federate its domain-specific GraphQL schemas—including those backed by knowledge graphs, microservices, or legacy APIs—into one cohesive endpoint for client applications.
Key components include:
- Subgraph: An independent GraphQL service that defines a portion of the overall schema for a specific domain (e.g., a 'Products' service, a 'Knowledge Graph' service).
- Supergraph Schema: A composed schema generated by the federation router that merges all subgraph schemas, resolving overlaps and dependencies.
- Federation Router/Gateway: The runtime component that receives client queries, intelligently plans their execution across relevant subgraphs, and merges the results.
This pattern is governed by the Apollo Federation specification, which has become a de facto standard, though other implementations exist.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
GraphQL Federation is a compositional architecture. These are the core concepts, protocols, and services that define its implementation and operation within a microservices landscape.
Schema Stitching
An alternative, lower-level pattern for merging multiple GraphQL schemas into a single unified API. Unlike Federation's declarative entity-based model, schema stitching involves programmatically merging type definitions and delegating resolvers. It offers more granular control but requires manual resolution of conflicts and a deeper understanding of the underlying GraphQL execution engine. Federation is generally preferred for its stronger conventions and tooling in large-scale microservices.
Supergraph
The composed, unified GraphQL schema and its associated routing logic that represents the entire federated API. It is the product of combining all subgraph schemas. The supergraph schema is consumed by the gateway/router, which uses it to validate incoming client queries and create an execution plan. Managing the supergraph's lifecycle—composition, validation, and deployment—is a central concern, often handled by tools like Apollo Rover or a schema registry.
Subgraph
An independent GraphQL service that defines a portion of the overall federated graph. Each subgraph:
- Manages a distinct domain or data source (e.g., a
Usersservice, aProductsservice, a Knowledge Graph backend). - Uses the Federation spec to declare entities it can resolve using the
@keydirective. - Can extend types defined by other subgraphs.
- Runs its own business logic and connects to its own databases. The federation gateway calls these services to resolve parts of a client's query.
Query Planning
The process performed by the federation gateway/router to decompose a single client GraphQL query into a series of sub-queries (or query shapes) destined for specific subgraphs. The planner must:
- Respect data dependencies and the
@requiresdirective. - Minimize the number of subgraph calls (e.g., via batching).
- Handle error boundaries for partial failures.
- Optimize the order of execution. This is a complex optimization problem critical to the performance of a federated architecture.
GraphQL Router (Gateway)
The runtime component that sits between clients and the federated subgraphs. Its primary responsibilities are:
- Schema Composition: Building the supergraph from subgraph schemas.
- Query Planning & Execution: Parsing client queries, creating an execution plan, calling subgraphs, and stitching results.
- Caching: Implementing query and response caching to improve performance.
- Observability: Collecting metrics and traces for all graph operations. Examples include the Apollo Router, Netflix's DGS Federation Gateway, and Wundergraph.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us