Realtime Subscriptions
Realtime starts with a simple rule: websocket auth is connection-scoped.
When the access token changes, terminate the websocket client. The next connection will send fresh connection params.
Browser Flow
- Relay environment creates a websocket client through the realtime adapter.
- Connection params read the current memory access token.
- Relay uses the websocket client for subscriptions.
- Auth-state subscription terminates the client when the token changes.
- The realtime package tracks reconnect state and browser online/offline state.
Server Flow
graphql-wsconnection params carry bearer auth.- Server GraphQL helpers extract auth from params.
- Server auth verifies the access token.
- The principal is stored in websocket
extra. - Subscription resolvers use the context principal.
For multiple server instances, add shared pub/sub such as Redis. Labkit does not hide that scaling decision because it affects your runtime architecture.