It’s been amazing to see the momentum grow around Apollo Federation with over 1M weekly downloads and 12K+ projects using Apollo Federation. Thanks to community contributions, the thriving ecosystem around Apollo Federation means you can federate subgraphs written in over 12 languages and frameworks.
Originally released in 2019, Federation powers some of the largest graphs in the world, including Netflix, Walmart, RetailMeNot, and PayPal. Developers are choosing Apollo Federation because it’s a proven approach for rapidly scaling a graph across multiple teams.
Today, we’re excited to celebrate the next major milestone: Apollo Federation 2. The new version builds on the success of the original with an improved shared ownership model, enhanced type merging, and cleaner syntax for a smoother developer experience. It’s backwards compatible, requiring no major changes to your subgraphs. Try the alpha today! 🚀
Apollo Federation 2
Apollo Federation is an architecture for declaratively composing subgraphs into a unified graph. Each team can own their slice of the graph independently, empowering them to deliver autonomously and incrementally.
Designed in collaboration with the GraphQL community, Federation 2 is a clean-sheet implementation of the core composition and query-planning engine at the heart of Apollo Federation. We’ve improved the developer experience by adding deeper static analysis, cleaner error messages, and new composition hints that help you catch errors sooner and understand how your schema impacts performance. With the new version, we’ve streamlined common tasks like extending a type and simplified advanced workflows like migrating a field across subgraphs with no downtime.
Following in the footsteps of modern infrastructure projects like Elasticsearch and MongoDB, we’re moving Federation 2 to the Elastic License v2 — an open and permissive license with few restrictions. This change shouldn’t affect the vast majority of our community, and the new code is still free to use and modify. Subgraph packages will remain MIT, as well as the 0.x Federation packages, so there are no changes to what you’re doing today.
Build with any natural GraphQL schema
Federation 2 adds first-class support for shared interfaces, enums, and other value types. Common tasks like extending a federated type or denormalizing a field for better performance are now possible without special directives and keywords.
Deliver smaller increments with better shared types
Apollo Federation already supports a shared ownership model that lets you spread a federated type across subgraphs to distribute its implementation. You can reuse common value types like interfaces and enums. However, there are restrictions on how shared types can be defined and evolved. As a result, teams may find themselves stuck when making changes to shared types until all subgraphs are able to deliver a coordinated change in lockstep.
Federation 2 removes these restrictions with an improved shared ownership model and enhanced type merging that enables teams to deliver smaller incremental changes with a cleaner separation of concerns.
Flexible value type merging is now supported, so value types don’t need to be identical across subgraphs. Value type definitions are now merged into a single unified type, much like type merging support for federated types today. Smaller incremental changes, like adding a field, can often be rolled out one subgraph at a time.
Federated types have improved shared ownership, which means fields can now exist in multiple subgraphs simultaneously. This paves the way for natively supported field migrations with an asynchronous transfer of ownership from one subgraph to another with no downtime or tight release coordination.
Catch errors sooner with improved static analysis
Federation 2 has deeper static analysis, better error messages and a new generalized composition model that helps you catch more errors at build-time instead of at runtime. The rewritten composition engine now validates all theoretically possible queries and provides more descriptive error messages when a query can’t be satisfied.
New composition hints help you understand how schema definitions influence query planning and performance. We’ve integrated them into the powerful tools for Apollo Federation:
- Apollo Workbench shows composition hints in the problems tray with new hover tips.
- Rover includes composition hints in both standard and structured JSON output so you can integrate them with other tools in your pipeline.
- Apollo Studio uses composition hints to help you ensure design guidelines and best practices.
While Federation 2 is backwards compatible, its enhanced validation might catch a few things that the original Federation didn’t. Things you’ll be happy to know about!
Quick tour of Federation 2
We’ve prepared this video to highlight some key improvements in Federation 2, including Apollo Workbench support for composition hints. You’ll also learn how to compose and run a graph with Federation 2 using the v2 gateway and Apollo Studio.
We’d love your early feedback on the initial alpha release!
There’s a lot we’re adding in the coming months:
- New directives that support a stronger source of truth, field migration across subgraphs, and type merging that can be relaxed even further.
- Expanded use of core schemas to compose your own directives in subgraphs and process supergraph schemas with a new core-schema-js library.
- Harmonizing shared value types across subgraphs to steward core common types to a desired state.
- Importing shared types into subgraph schemas, to keep things more DRY.
- Advanced caching, auth, demand control, rate limiting, governance, and more!
Learn more at GraphQL Summit
See Federation 2 in action at GraphQL Summit on November 10th and 11th, 2021.
Register for free and join us for the keynote and a deep dive session on “The Future of Apollo Federation.” We’ll discuss and demo Federation 2, designed in collaboration with Netflix, to make it even easier to build, use and scale your graph!
Phil is a Director of Product at Apollo GraphQL with 20 years' experience in product and engineering roles building successful new products at startups and large enterprises.
Stay in our orbit!
Become an Apollo insider and get first access to new features, best practices, and community events. Oh, and no junk mail. Ever.
Make this article better!
Was this post helpful? Have suggestions? Consider so we can improve it for future readers ✨.