-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Feature Request
Is your feature request related to a problem? Please describe.
While NestJS does expose the onConnect and onDisconnect hooks in the subscriptions options object, I am looking to maintain class instances that manage the client's state for the duration of their websocket connection from within the DI context.
Describe the solution you'd like
I don't know how feasible this is, but it would be great to simply define the scope via @Module({ scope: GRAPHQL_WS_CONNECTION }). I am open to any solution, however.
Teachability, Documentation, Adoption, Migration Strategy
What is the motivation / use case for changing the behavior?
When the websocket connection establishes from the client, I need to open up multiple streams of data from which I aggregate state, which I use to determine when/if I should push updates to the client, based on their open subscriptions. As there isn't a 1-to-1 relationship between subscriptions and needed backend streams, opening up streams per-subscription leads to a lot of duplicate data and processing.