Company
Date Published
Author
Liz Hennessy
Word count
1874
Language
English
Hacker News points
None

Summary

The article explains how Apollo Router supports federated subscriptions using the HTTP callback protocol. This allows subgraphs to communicate updates to the router without maintaining long-lived, resource-intensive connections common with WebSocket approaches. The process involves three primary roles: the router, the subgraph, and the emitter. The router receives a subscription operation, sends it to the responsible subgraph, and attaches instructions for how the subgraph can "call back." The subgraph then acts as both the subgraph and the emitter, sending regular "check" messages to the router at predefined intervals, providing updates via a "next" message when something changes, and closing a subscription connection with the router. This enables subscriptions across multiple subgraphs without the weight of multiple long-term WebSocket connections, allowing clients to receive data from multiple sources in a single operation.