Skip to content

Interface: GraphQLWsSubscriptionsOptions

Defined in: packages/apollo/src/interfaces/apollo-options.interface.ts:92

Options for GraphQL WebSocket subscriptions (graphql-ws protocol).

Properties

PropertyTypeDescriptionDefined in
connectionInitWaitTimeout?numberTimeout for connection initialization in milliseconds.packages/apollo/src/interfaces/apollo-options.interface.ts:96
keepAlive?number | falseServer-side keep-alive interval in milliseconds. Sends periodic ping messages to prevent idle connections from being closed by proxies, load balancers, or NAT. Set to 0 or false to disable. Default 12000packages/apollo/src/interfaces/apollo-options.interface.ts:103
keepAliveTimeout?number | falseInactivity timeout in milliseconds. When the client stops responding (no pong, no messages) for longer than this window, the server force-closes the socket — triggering cleanup of all of the connection's subscription iterators. Protects against dirty TCP disconnects (mobile hibernation, half-open connections, rapid reconnect under flaky Wi-Fi) where the kernel would otherwise take minutes to detect the dead peer, causing pubSub.asyncIterator() instances to leak in subscriptionMap. When unset, defaults to 2 × keepAlive. Set to 0 or false to disable entirely.packages/apollo/src/interfaces/apollo-options.interface.ts:119
onClose?(context) => void | Promise<void>Callback when a connection closes.packages/apollo/src/interfaces/apollo-options.interface.ts:148
onConnect?(context) => | boolean | void | Record<string, unknown> | Promise<boolean | void | Record<string, unknown>>Callback when a client connects.packages/apollo/src/interfaces/apollo-options.interface.ts:138
onDisconnect?(context) => void | Promise<void>Callback when a client disconnects.packages/apollo/src/interfaces/apollo-options.interface.ts:146
onNext?(context, id, payload, args, result) => void | Promise<void>Callback when a subscription emits a value.packages/apollo/src/interfaces/apollo-options.interface.ts:160
onSubscribe?(context, id, payload) => | void | ExecutionArgs | readonly GraphQLError[] | Promise<void | ExecutionArgs | readonly GraphQLError[]>Callback when a subscription is created.packages/apollo/src/interfaces/apollo-options.interface.ts:150
path?stringWebSocket endpoint path.packages/apollo/src/interfaces/apollo-options.interface.ts:94
transportIdleTimeout?numberTransport-level idle timeout, in seconds, forwarded to Bun's ws.idleTimeout. When the WebSocket is silent for this many seconds in both directions, uWebSockets closes the connection at the transport layer, guaranteeing cleanup even if the application-level watchdog is disabled. Prefer this over keepAliveTimeout when possible — it's handled natively and doesn't require a JS timer per connection. Values are in seconds to match Bun's API. When unset, derived from keepAliveTimeout (+ 5s grace) so the transport closes shortly after the app-level watchdog would fire. Falls back to Bun's 120s default when neither is set. Maximum: 960 (Bun hard limit).packages/apollo/src/interfaces/apollo-options.interface.ts:136

Released under the MIT License.