You can subscribe to a query and receive live updates whenever the result of the query changes. The query can be as large and nested as you need it to be.

This is by far one of the coolest features of GraphJin and you'd be hardpressed to find similar functionality elsewhere.


Using subscriptions


If you use the standalone service then subscriptions will work over websockets using a GraphQL client like Apollo or URQL

If your using GraphJin as a library in your NodeJS or Go code then read ahead.

subscription getUserUpdates {
  users(id: $id) {
NodeJS code
const res = await gj.subscribeByName("getUserUpdates", { "id": 3 }) {
GO code
c := context.Background()
vars := json.RawMessage(`{ "id": 3 }`)
m, err := gj.SubscribeByName(c, "getUserUpdates", vars, nil)
if err != nil {
  return err
for {
  msg := <-m.Result

Highly scalable


In GraphJin subscriptions are designed to be highly scalable. You can easily handle tens of thousands of subscribers on a relatively a basic server, even your database server can be pretty basic. This is because GraphJin uses only a single database query for thousands of connections.

Compare this to traditional client side polling solutions which require as many query as subscribers. With GraphJin you can now add realtime updates to your application without the worry of database load.

For very large deployments it scales horizontally and vertically as in can leverage more CPU and memory added per instance as well as read-replicas or a distributed database like Yugabyte.

No additional configuration is needed for subscriptions except for the poll_every_seconds: 3 config parameter to control how often GraphJin should check for updates.