Subscriptions allow clients to receive real-time push updates from the server over a persistent WebSocket connection. Enable them by setting the subscriptions option in GraphQLModule.forRoot(). NestJS supports two transports: graphql-ws (modern, recommended) and subscriptions-transport-ws (legacy Apollo client).
graphql-ws — RFC-compliant modern protocol; use with graphql-ws client library.
subscriptions-transport-ws — legacy Apollo protocol; needed if clients use apollo-link-ws.
Install graphql-ws and ws packages: npm i graphql-ws ws.
Subscriptions require a persistent WebSocket connection — HTTP long-polling is not supported.
Both transports can be enabled simultaneously for backward compatibility during client migrations.