Make it possible to skipResult() inside of onSubscribe.onSubscribeResult.onNext
envelop plugin to avoid/skip re-send unchanged data
#2331
Labels
kind/enhancement
New feature or request
Problem
I was recently researching the best approaches to implement real-time subscriptions sync with database and came across Hasura's approach.
https://github.com/hasura/graphql-engine/blob/master/architecture/live-queries.md#when-do-we-refetch
Instead of watching to real database events, they are syncing at every 1 second, and the justifications are quite reasonable.
Furthermore, in order to optimize resources, they avoid sending same data over the network every 1 second, they only send if it changed. Which also makes perfect sense.
Inside of Schema builder, its simple to make the resolver call every 1 second.
But getting it to avoid sending duplicate messages seems to be a challenge.
Solution
From Envelop plguins, we can create a custom functions to "rewrite" the result of each data response of subscription, but there is no API to avoid/skip sending it.
I think with a new option called
skipResult
It would make it possible to create a cache like Hasura's for SubscriptionsDoes this make any sense?
I took a good dive into the core/plugins code, did several tests/changes but always tried to avoid sending the expected data, graphql-ws threw an error
The text was updated successfully, but these errors were encountered: