Boosting Self-Hosted GraphQL API Performance With Apollo Router and Federation
Apollo Studio and Supergraph provide a streamlined solution for companies to integrate their data, microservices, and business logic into a single connected graph.
Join the DZone community and get the full member experience.
Join For FreeThe Apollo router is a software component that replaces the GraphQL Gateway and is implemented using the RUST programming language. It offers a highly configurable, loosely coupled, and high-performance routing solution for self-hosted graphs. The Apollo router enables developers to easily manage and route queries between different GraphQL services within an organization. It provides flexibility in configuration and has a low overhead, resulting in faster response times and improved performance.
In addition to the Apollo router, Apollo Federation is an open architecture that combines multiple GraphQL APIs into a single graph. It enables developers to break up a monolithic GraphQL schema into smaller, independently deployable services, which can then be combined into a single, unified graph. With Apollo Federation, developers can build scalable, modular GraphQL APIs that can be easily maintained and extended over time. The result is a more flexible and agile approach to building GraphQL APIs that can adapt to changing business needs and requirements.
The diagram below represents various components integrated with the Apollo router and explains how client and server interactions are routed through the Apollo router.
Apollo Studio and Supergraph
The enterprise version of Apollo supports schema registry through Apollo Studio, a SaaS application that combines all the subgraphs into a Supergraph using Rover CLI.
Apollo GraphQL enables companies to build their "supergraph," a new layer in the tech stack that integrates a company's data, microservices, and business logic into a single connected graph. Unlike REST APIs, which require developers to create a new connection between data and client every time they need to build a new feature or product, GraphQL, and the supergraph allow developers to request the data they need from a specific business object in a declarative way. This enables them to build better apps faster, as the data is delivered to them in a more efficient and streamlined manner.
Three core principles underlie the Supergraph concept:
- A new unified composition layer: The Supergraph connects the company's data, microservices, and digital capabilities into a new unified composition layer.
- A modular approach: Supergraph's modular and declarative architecture allows teams to quickly integrate modular data, services, and business logic.
- Agile approach: Bottom-up development is faster and more involved than top-down development. Each developer and team are encouraged to publish changes into the schema, and the actual use of the schema pushes development forward by keeping everyone focused on decisions and improvement.
Apollo Federation
Apollo Federation is responsible for composing multiple subgraphs (GraphQL services) into a supergraph. Each subgraph is a self-contained component with its own schema, which can be developed and deployed independently using the modular principle. The approach is bottom-up and flexible, as subgraphs can be written in 20 different programming languages, allowing for greater versatility and adaptability.
Apollo Router
The Apollo Router is responsible for running the Supergraph, providing a high-performance runtime solution. As a successor to Apollo Gateway, it offers significantly improved performance, with 10 times lower latency, 10 times higher throughput, and 12 times lower variance than JavaScript.
The Supergraph is produced by Apollo Studio, which enables developers to make changes quickly and safely through validation, automation, and observability. This is particularly important in the rapidly evolving Supergraph environment, where developers and teams collaborate and contribute to each other's work. By using Schema Checks and Launches, the schema can be automatically validated in development, preventing breaking changes and making past and ongoing changes more apparent.
In conclusion, Apollo Studio and Supergraph provide an efficient and streamlined solution for companies to integrate their data, microservices, and business logic into a single connected graph. The enterprise version of Apollo supports schema registry through Apollo Studio, and each subgraph can be developed and deployed independently using the modular principle. Apollo Federation is responsible for composing multiple subgraphs into a supergraph, while the Apollo Router provides a high-performance runtime solution for running the Supergraph. By using Schema Checks and Launches, developers can make changes quickly and safely, with validation, automation, and observability ensuring a smooth and collaborative environment.
Opinions expressed by DZone contributors are their own.
Comments