Repository navigation
feat(graphql): accept a custom ws server for graphql-ws subscriptions - #4105
Conversation
|
Opus: Nice feature. One blocking issue, two smaller ones: Blocking - custom server's
No check that the custom server used Also: the new tests fully mock |
… config Allow users to provide a custom WebSocket server instance via the 'server' option in graphql-ws configuration. Closes nestjs#2653
ba5d3cf to
2a1320b
Compare
Thanks for the thorough review @kamilmysliwiec! All points have been addressed:
|
Keep handing upgrades with an unsupported subprotocol to graphql-ws, so clients are answered instead of left hanging, and resolve the upgrade path once. Type the custom server structurally, so the public types don't require @types/ws. Add e2e tests for routing, ws options and shutdown on both adapters.
Description
Following the v14 release, this PR adds support for providing a custom WebSocket server instance via the
serveroption in thegraphql-wssubscriptions configuration.When provided,
@nestjs/graphqlwill use the givenWebSocketServerinstance instead of creating the default one.Closes #2653
Motivation
Allows users to pass their own pre-configured WebSocket server instance (e.g. for custom connection handlers, compression settings, or alternative server setups) to
graphql-ws.Types of changes
Checklist: