@@ -4,21 +4,21 @@ sidebarTitle: Federation
4
4
5
5
import { Tabs } from ' nextra/components'
6
6
7
- # GraphQL Federation
7
+ # GraphQL federation
8
8
9
9
As applications grow more complex, traditional monolithic approaches often fall short. At scale,
10
10
monolithic architectures can become cumbersome, brittle, and increasingly hard to test and validate.
11
11
This has led to a rise in the adoption of new patterns like distributed systems and microservices.
12
- In some ways, GraphQL Federation is like microservices for GraphQL – an architectural pattern that
12
+ In some ways, GraphQL federation is like microservices for GraphQL - an architectural pattern that
13
13
has found particular resonance in the GraphQL ecosystem.
14
14
15
- GraphQL Federation gained widespread adoption after
15
+ GraphQL federation gained widespread adoption after
16
16
[ Apollo GraphQL introduced Apollo Federation in 2019] ( https://www.apollographql.com/blog/apollo-federation-f260cf525d21 ) .
17
17
Their implementation has become a reference point for the GraphQL community, helping establish
18
18
federation as a standard architectural pattern for building a distributed graph in the GraphQL
19
19
ecosystem.
20
20
21
- With more companies and developers seeing the benefits of building a distributed graph with
21
+ With more companies and developers seeing the benefits of building a distributed GraphQL schema with
22
22
federation, the GraphQL ecosystem is now moving towards standardization of federation patterns. The
23
23
GraphQL Foundation's
24
24
[ Composite Schema Working Group] ( https://github.com/graphql/composite-schemas-wg ) , which includes
@@ -50,14 +50,14 @@ Think of the "Login with Google" or "Login with Facebook" buttons you see on web
50
50
federation in action: you can use your Google or Facebook account to log into many different
51
51
websites, even though each company manages their own login system separately.
52
52
53
- ## What Is Federated GraphQL?
53
+ ## What is federated GraphQL?
54
54
55
- GraphQL Federation applies those principles to GraphQL APIs. It enables organizations to build a
55
+ GraphQL federation applies those principles to GraphQL APIs. It enables organizations to build a
56
56
unified GraphQL schema from multiple independent services (most often called subgraphs), each
57
57
responsible for its portion of the application's data graph.
58
58
59
59
Consider an e-commerce platform: You might have separate teams managing products, user accounts, and
60
- order processing. With GraphQL Federation , each team can:
60
+ order processing. With GraphQL federation , each team can:
61
61
62
62
- Define their own GraphQL schema
63
63
- Deploy and scale their service independently
@@ -67,7 +67,7 @@ order processing. With GraphQL Federation, each team can:
67
67
The magic happens through a federated gateway that acts as the central coordinator, composing these
68
68
separate schemas into a unified schema that clients can query.
69
69
70
- ## How Federation Works in GraphQL
70
+ ## How federation works in GraphQL
71
71
72
72
The federation process involves several key components:
73
73
@@ -122,7 +122,7 @@ type Order {
122
122
123
123
</Tabs .Tab > </Tabs >
124
124
125
- ### Schema Composition
125
+ ### Schema composition
126
126
127
127
Let 's break down schema composition in GraphQL federation with more detail and examples. Schema
128
128
composition is the process where multiple subgraph schemas are combined into one unified schema.
@@ -205,58 +205,58 @@ query {
205
205
The gateway will route parts of the query to the appropriate subgraphs, collect the results, and
206
206
assemble them into a single response that the client can consume.
207
207
208
- ## Benefits of GraphQL Federation
208
+ ## Benefits of GraphQL federation
209
209
210
- ### Domain-Driven Development
210
+ ### Domain-driven development
211
211
212
212
Teams can work independently on their services while contributing to a cohesive API. This autonomy
213
213
accelerates development and reduces coordination overhead.
214
214
215
- ### Service Integrity Protection
215
+ ### Service integrity protection
216
216
217
217
The schema composition step verifies integration between services by ensuring that changes in
218
218
individual subgraphs do not conflict with other subgraphs.
219
219
220
- ### Scalability and Performance
220
+ ### Scalability and performance
221
221
222
222
Subgraphs and services can be scaled independently based on their specific requirements. The product
223
223
catalog might need different scaling characteristics than the order processing system.
224
224
225
- ### Single, Unified API
225
+ ### Single, unified API
226
226
227
227
Thanks to GraphQL, clients get a single endpoint with unified schema spanning multiple subgraphs.
228
228
The complexity of distributed systems is hidden. The gateway ensures every query reaches its
229
229
destination and returns with the right data.
230
230
231
- ## Is GraphQL Federation Right for You ?
231
+ ## Is GraphQL federation right for you ?
232
232
233
- GraphQL Federation aligns naturally with Domain Driven Design (DDD) principles by allowing teams to
233
+ GraphQL federation aligns naturally with Domain Driven Design (DDD) principles by allowing teams to
234
234
maintain clear boundaries around their domains, while maintaining explicit integration points
235
235
through the GraphQL schema. It is particularly valuable for organizations where multiple teams need
236
236
to work independently on different parts of the GraphQL API, with the flexibility to use different
237
237
technologies and programming languages.
238
238
239
- However, implementing Federation requires substantial infrastructure support, including a dedicated
239
+ However, implementing federation requires substantial infrastructure support, including a dedicated
240
240
team to manage the gateway, schema registry, to help connect subgraphs to the federated API and guide
241
241
teams on best practices.
242
242
243
- Before adopting Federation , it's crucial to consider whether your organization truly needs this
243
+ Before adopting federation , it's crucial to consider whether your organization truly needs this
244
244
level of complexity.
245
245
246
246
Meta (formerly Facebook), [ where GraphQL was created] ( /blog/2015-09-14-graphql/ ) , has continued to
247
247
use a monolithic GraphQL API since 2012. However, companies like
248
248
[ Netflix] ( https://netflixtechblog.com/how-netflix-scales-its-api-with-graphql-federation-part-1-ae3557c187e2 ) ,
249
249
[ Expedia Group] ( https://youtu.be/kpeVT7J6Bsw?si=srGWsoxf3kTmneTu&t=79 ) ,
250
250
[ Volvo] ( https://www.apollographql.com/blog/volvo-cars-drives-into-the-future-of-online-car-shopping-with-the-supergraph ) ,
251
- and [ Booking] ( https://youtu.be/2KsP_x50tGk?si=mu-MOG-xZQSDNDjh&t=478 ) have adopted Federation to
251
+ and [ Booking] ( https://youtu.be/2KsP_x50tGk?si=mu-MOG-xZQSDNDjh&t=478 ) have adopted federation to
252
252
better align with their organizational structures and microservices architecture.
253
253
254
- As you see, many industry leaders successfully federated their GraphQL APIs, proving that it works
255
- reliably for large-scale production applications.
254
+ As you see, some of the world's largest industry leaders have successfully federated their GraphQL APIs,
255
+ proving that it works reliably for production applications at an extraordinary scale .
256
256
257
- ## Getting Started with GraphQL Federation
257
+ ## Getting started with GraphQL federation
258
258
259
- If you're considering adopting GraphQL Federation , here are some steps to get started:
259
+ If you're considering adopting GraphQL federation , here are some steps to get started:
260
260
261
261
1 . ** Identify Service Boundaries** : Define clear boundaries between different domains in your
262
262
application
@@ -269,6 +269,6 @@ If you're considering adopting GraphQL Federation, here are some steps to get st
269
269
5 . [ ** Use a Schema Registry** ] ( /community/tools-and-libraries/?tags=schema-registry ' Discover a list of GraphQL schema registries in our Tools and Libraries page ') :
270
270
Manage schema composition and validation to ensure integrity across subgraphs
271
271
272
- When migrating from a monolithic GraphQL API to Federation , the simplest starting point is to treat
272
+ When migrating from a monolithic to federated GraphQL API , the simplest starting point is to treat
273
273
your existing schema as your first subgraph. From there, you can follow the steps above to gradually
274
274
decompose your schema into smaller pieces.
0 commit comments