I am very new to GraphQL, so maybe I am just missing something here. i am currently creating an GraphQL endpoint of a Postgres SQL Database using the PostGraphile I am able to perform queries, but i just found out about GraphQL Subscriptions and apparently PostGraphile supports it as explained here. Here its what I doing.
Express Server
const express = require("express");
const { postgraphile, makePluginHook } = require("postgraphile");
const { default: PgPubsub } = require("@graphile/pg-pubsub");
const pluginHook = makePluginHook([PgPubsub]);
var cors = require('cors');
const app = express();
app.use(cors());
let url = "postgres://postgres:docker@localhost:5432/dvdrental";
app.use(postgraphile(url,"public", {
graphiql:true,
pluginHook,
subscriptions: true,
simpleSubscriptions: true,
}));
app.listen(3000);
Subscribing like
subscription {
listen(topic: "hello") {
query {
allPayments {
nodes {
customerId
paymentDate
nodeId
}
}
}
}
}
Triggering like
postgres=# select pg_notify( 'postgraphile:hello', '{}' );
But I am not seeing anything on the graphiql response
WebSocket/Network
Here it is what I get at the WebSocket/Network panel @Benjie.
The {type:"ka}
actions appears to be fired in a random interval.