question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Event-based subscriptions

See original GitHub issue

Reopen of #1355 .

To inspect whether it is good to use event-based subscriptions or live queries, I’ve gone through many articles and found this comment best describes the current state of live queries and event-based subscriptions.

There are still use cases of event-based subscriptions, especially when performance count more than reliability (take an example of twitter like subscription)

Another thing is that, most subscriptions in the current graphql ecosystem use event-based ones. It will be hacky to convert an existing project with subscriptions to hasura.

The hacky part of using live query for event-based subscriptions is that

  1. It will be difficult or at least not straight-forward to detect row deletion. #1201
  2. It will yield unnecessary initial results.
  3. Tracking update or create events need extra effort (adding updated_at columns to sort with, etc.)

cc: @coco98

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:28
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

18reactions
barbalexcommented, Nov 14, 2020

@heyrict One of the biggest challenges/decisions with event based subscriptions is how does the client recover from loss of events? Does the server store what events are delivered to clients? This involves maintaining state at the server (using something like a message queue maybe?) and becomes even more complicated when you bring in horizontal scalability of the subscriptions server.

We support live queries because they are easy to reason about, very expressive, extremely performant and the server need not store any state (in our implementation).

@0x777

The problem with live queries is that they always deliver all the information.

Say I have a table with 10’000 records. One of them changes. So the live query fires. Now my application needs to find out which record changed in order to update it client side. So it has to compare all 10’000 records!

If event based subscriptions existed, the client could:

  • at startup: do the expensive comparison only once to ensure all data is up to date (actually the client only needs to query data changed since the last startup)
  • start the event based subscription
  • cheaply update only the changed records when events happen

This seems so obvious I am sure I must have missed something essential. What have I missed?

6reactions
bknifflercommented, Sep 2, 2019

One thing I’ve found is, it is very hard to write a mutation that would optimistically update a subscription with apollo, or maybe even impossible, since apollo doesn’t seem to have build in mechanisms to automatically update subscriptions (using optimisticResponse) and there is no possibility to read/write subscriptions from/to cache. This must be due to the fact that, as @heyrict states, most implementations and even apollo docs use event based subscriptions instead of live queries.

Would love to see some workaround for live-queries + optimistic response, I couldn’t manage to get this combination to work with apollo.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Feature: Webhook Subscriptions - Laboperator
Webhook Subscriptions enable the receiving of push notifications on specific events as an HTTP POST request to a pre-set URL in Laboperator.
Read more >
Event Subscriptions (Oracle Workflow Developer's Guide)
You can improve performance by specifying Key as the rule data for subscriptions that do not require the complete event data. For locally...
Read more >
Event subscription best practices | Adobe Workfront
Provide all required request body fields · Avoid including extra body fields · Complete testing within the grace period · Meet the Standard...
Read more >
Getting started with subscriptions - IBM Cloud Docs
Applications can subscribe to multiple event producers, but only one app can receive events from each subscription. Note that subscriptions can affect how...
Read more >
Activate Event-Based Component | Stoplight Platform API Docs
In order to bill your subscribers on your Events data under the Events-Based Billing feature, the components must be activated for the subscriber....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found