A GraphQL subscriptions implementation using PostgreSQL and Apollo's graphql-subscriptions PubSubEngine interface. v3.3.0 is the current stable release. This package allows multiple subscription manager instances to share a PostgreSQL-based PubSub mechanism, supporting large payloads via an optional table (usePayloadTable) to bypass PG NOTIFY's 8000-byte limit. It provides TypeScript types, a commonMessageHandler for transforming messages (e.g. injecting DataLoaders), and an 'error' event for handling failures like oversized payloads. Actively maintained by a solo developer with a focus on simplicity and small size, it works with Express.js and NestJS but is not designed for high-throughput or clustered deployments without additional configuration.
npm install graphql-pg-subscriptionsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to PostgreSQL, initializing PostgresPubSub with large payload support, subscribing to errors, publishing messages, and subscribing to events.
Upgrade to v3 and wrap the client in an object: `new PostgresPubSub({ client })`.Set `usePayloadTable: true` in the constructor options if you need to bypass PG NOTIFY's size limit.
Use `PostgresPubSub` directly and configure your GraphQL server according to its supported subscription setup (e.g., `graphql-subscriptions` with `PubSub.asyncIterator`).
Set `usePayloadTable: true` in the constructor to store payloads in a PostgreSQL table, circumventing the NOTIFY size limit.
Implement your own reconnection logic for the pg client (e.g., using `pg`'s `Client` with `reconnect` option or a connection pool) and create a new PostgresPubSub instance after reconnection.
Use `const pubsub = new PostgresPubSub({ client })` instead of `PostgresPubSub(...)`.Use named import: `import { PostgresPubSub } from 'graphql-pg-subscriptions'`.Set `usePayloadTable: true` in the constructor options or ensure payloads are under 8000 bytes.