Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphQL WebSocket Connection Scope #6253

Closed
flux627 opened this issue Jan 27, 2021 · 3 comments
Closed

GraphQL WebSocket Connection Scope #6253

flux627 opened this issue Jan 27, 2021 · 3 comments
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@flux627
Copy link

flux627 commented Jan 27, 2021

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.

@flux627 flux627 added needs triage This issue has not been looked into type: enhancement 🐺 labels Jan 27, 2021
@kamilmysliwiec
Copy link
Member

As this #4287 is a very similar issue, let's track it there in one place

@flux627
Copy link
Author

flux627 commented Jan 27, 2021

Thanks for bringing this other issue my attention.

Would you have any suggestions for the best way to use onConnect and onDisconnect to effectively achieve what I need, as a workaround?

@flux627
Copy link
Author

flux627 commented Jan 28, 2021

@kamilmysliwiec not sure if this has visibility to you since the issue is now closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

2 participants