Skip to main content
Version: Draft

Live Queries

A “live query” monitors the query a user provides and gives the client an updated version whenever the query would return a different result.

Status

Live queries are planned for a future PostGraphile V5 release. For now, use standard GraphQL subscriptions for real-time updates. The Real-time features page covers the subscription options currently available.

Subscriptions should generally be preferred over live queries

Subscriptions work on an event basis and are very scalable for that reason - look into pubsub scalability. They're also expressive, and can tell you things that your data might not - for example "Benjie is typing..." might not be a state that you store permanently to the database, but is is a reasonable event.

Live queries on the other hand require a reactive datastore (or polling) to try and keep a particular query up to date whenever something under the query might cause it to change. It's very hard to achieve especially when combining multiple data sources, and is often a lot "noisier" on the network. There is not yet a GraphQL standard for live queries.

The PostGraphile V4 implementation of live queries was highly experimental and had significant issues. Grafast should allow a much more powerful, performant, and stable implementation, but it has not been built yet. If you want live queries in V5, please sponsor the feature or reach out to work on it together.