The Apollo team wants to help developers adopt GraphQL within their microservice architectures with the announcement of its open-source project Apollo Federation.

According to Apollo’s engineering manager James Baxley III, developers want to be able to access data through a single GraphQL query even if that data lives in separate places. Before Apollo Federation, Baxley explained that type of action was only really possible in a monolithic architecture.

RELATED CONTENT: With microservices, more isn’t always better
How GraphQL is competing with REST

“Apollo Federation is inspired by years of conversations with teams that use GraphQL to power their most important projects. Time and time again, we’ve heard from developers that they need an efficient way to connect data across services,” Baxley wrote in a blog post.

He went on to explain that the project is ideal for implementing GraphQL in a microservice architecture because it brings together the best of both worlds: a complete scheme to connect data and a distributed architecture for specific teams to tailor to their portion of the graph.

“Ideally, we want to expose one graph for all of our organization’s data without experiencing the pitfalls of a monolith,” Baxley wrote. “It’s designed to replace schema stitching and solve pain points such as coordination, separation of concerns, and brittle gateway code.”

With Apollo Federation, users can declaratively reference types that live in different schemas and organize services by concern.

It also includes production-ready features such as multiple primary keys that can reference types, compound primary keys that can be any valid selection set, and shortcuts for faster data fetching.

Federation is built on four core principles:

  • Building a graph should be declarative. Composing graphs declaratively in a schema replaces the need to stitch code imperatively.
  • Code should be separated by concern, not by types. The definition of these types should be distributed across teams and codebases, rather than centralized.
  • The graph should be simple for clients to consume. Federated services offers a product-focused graph that accurately reflects how it’s being consumed on the client.
  • It’s just GraphQL, using only spec-compliant features of the language. Any language can implement federation.