$ show apollographql/router
Apollo Router is a production-grade GraphQL gateway written in Rust. It accepts incoming GraphQL HTTP requests, composes a supergraph schema from subgraph schemas, plans queries across subgraphs, and executes them through a tower-style service pipeline. It supports federation, subscriptions, persisted queries, demand control, entity caching, progressive overrides, connectors, and defer. Configuration is YAML-based and can be managed via Apollo GraphOS Uplink for schema/config propagation.
The LLM identified 5 files worth highlighting for reuse:
Defines the Plugin trait and register_plugin! macro that form the router's extension point. Lifecycle hooks such as PluginInit, supergraph_service, execution_service, and web_endpoints let external code intercept and modify requests/responses. This is the core pattern behind the router's extensibility and is demonstrated by self-contained examples under examples/.
A minimal, self-contained example of implementing the Plugin trait and register_plugin! macro. It inspects GraphQL operations and rejects anonymous requests. This is a clean template for building custom router plugins.
Reusable example utility for propagating HTTP status codes through the router service pipeline. Demonstrates how to override response status codes in a Rust plugin and includes tests for the override behavior.
Implements hot-reloadable configuration via file watching, static config, and stream-based updates. This is a reusable pattern for managing live configuration updates in long-running services.
Collects OS, CPU, memory, container detection, and load averages for telemetry enrichment. Self-contained system-info collector that can be reused in any Rust service needing host metrics.