Architecture, protocol contracts, and integration requirements for GraphQL subscriptions and live data through Mundi
This page outlines the architecture, protocol contracts, and integration
requirements for streaming real-time data through the AxonMundi router (Mundi).
It is intended for frontend engineers consuming live data and backend engineers
evaluating or implementing subgraphs for event-driven data sources.
The Cosmo Router is a federated GraphQL gateway. It does not terminate arbitrary third-party WebSockets, proprietary socket streams, or raw message protocols directly into the graph.
To ingest live data from an upstream push stream (such as a vendor WebSocket,
event stream, or message broker), you must introduce a subgraph service that
acts as a protocol bridge and state manager. That service connects to the upstream
source, reconstructs and caches state, and exposes standard GraphQL
Subscription fields. Mundi then proxies client subscription operations to the
subgraph.
A client establishes a single WebSocket connection to Mundi for subscriptions. When an upstream event occurs, the subgraph processes the event, emits the corresponding GraphQL payload, and Mundi delivers it over the active client subscription.
Understanding environment gating is critical before planning live data features:
security.block_subscriptions.enabled: true).
They will remain blocked until live delivery for additional subgraphs is
formally approved and hardened.graphql-transport-ws (the modern
standard protocol used by Apollo Client's GraphQLWsLink) and legacy
graphql-ws. Prepared911 clients standardize on graphql-transport-ws.Browsers cannot attach custom HTTP headers (such as Authorization) to the
initial HTTP Upgrade request during a WebSocket handshake. Consequently, client
authentication credentials must be sent inside the connection_init payload
immediately after the socket opens:
The router extracts this payload and forwards it upstream to the subgraph's connection context.
Security requirements:
When Mundi reloads its execution configuration (for instance, following a newly published subgraph composition), all active client WebSocket subscriptions are terminated. Client implementations must treat WebSocket disconnections as normal operational events and implement automatic reconnection with exponential backoff and randomized jitter.
When designing a subgraph that interfaces with live data, take the following constraints into account:
Subscription
type or @edfs__* directives.Authorization header to subgraphs.
Before introducing a non-Prepared or third-party subgraph, authorization
forwarding must be scoped per subgraph in the router configuration to prevent
inadvertent credential leakage.Follow this sequence when bringing an upstream push-based source into the graph:
updatedAt timestamp or version cursor, allowing clients to poll. Polling
avoids persistent connection management overhead and fits existing HTTP
infrastructure.gqlgen) that owns the upstream connection, handles jittered reconnects,
maintains state in a bounded cache, and exposes standard GraphQL
subscriptions.just subscription-isolation-smoke in
AxonMundi for the baseline pattern.Cosmo Streams allows the router to subscribe directly to event brokers such as Kafka, NATS, or Redis, routing incoming topics directly to client GraphQL subscriptions without custom WebSocket subgraphs.
In this architecture, the brokers serve as the transport between your backend and the router; browser clients still connect to Mundi via standard GraphQL subscriptions. While architecturally clean, Cosmo Streams is currently unproven in this deployment, requires broker infrastructure we do not currently operate for this purpose, and remains a future architectural spike rather than an active integration path.
When consuming subscriptions in frontend applications:
useSubscription alongside useQuery from
@apollo/client, matching the patterns described in the
GraphQL operations guide.On this page