kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 309 forks source link

Feedback for “Subscriptions” #1975

Closed boomdizz closed 1 week ago

boomdizz commented 1 year ago

Since Subscriptions are long-lived operations (compared to Queries and Mutations), we need a means to terminate the subscription. A usecase we have is to show monitoring data for a bunch of hosts we manage. We have a webpage where the user selects a host from a drop down list (or select list) and we get it's monitoring data from the backend, display it and then use subscribeToMore to fetch new data as it becomes available on the backend. But if the user uses the drop-down for another host, we want to start the subscription for data on the new host. At this point we want to 'unsubscribe' for the old host, otherwise the backend will unnecessarily be consuming resources to send data to the client which will not be shown in the UI. It is best to have an option to unsubscribe as it conserves resources on the client and server end. Maybe there is a way of doing this, but I could not find it in the documentation.