Reactive queries for PostgreSQL

This video from learn.hasura shows them manually updating the cache on each mutation. https://youtu.be/qHPGWfpqQ3o

1 Like

But that is invalidation on the client, no? So you invalidate client cache which is just for the client who made the mutation. But for all other clients who are observing the list in other browsers their cache is not invalidated?

1 Like

@mitar Hi, sorry for waking this up again. Have you seen Supabase Realtime by supabase.io? - It’s built on Elixir and open source. They successfully and efficiently implemented Postgres realtime with Docker. Maybe you should look how it was implemented. Here is an example:

import { Socket } = '@supabase/realtime-js'

var socket = new Socket(process.env.REALTIME_URL)
socket.connect()

// Listen to only INSERTS on the 'users' table in the 'public' schema
var allChanges = this.socket.channel('realtime:public:users')
  .join()
  .on('INSERT', payload => { console.log('Update received!', payload) })

// Listen to all changes from the 'public' schema
var allChanges = this.socket.channel('realtime:public')
  .join()
  .on('*', payload => { console.log('Update received!', payload) })

// Listen to all changes in the database
let allChanges = this.socket.channel('realtime:*')
  .join()
  .on('*', payload => { console.log('Update received!', payload) })

Also, an example NodeJS app with Postgres Realtime

1 Like

Hello @mitar, can you point to some more info regarding this? What is “Meteor’s polling strategy”? Are you talking about GraphQL? Or Mongo/Minimongo?

That is when Meteor cannot use oplog to get changes from MongoDB, then it runs a query every 10 seconds and diffs with results from the last time.

1 Like