graphql-redis-subscriptions
graphql-redis-subscriptions copied to clipboard
node-redis package not compatible
trafficstars
import { RedisPubSub } from 'graphql-redis-subscriptions';
import { createClient } from 'redis';
const url = `redis://default:PASS@HOST:PORT`;
const client = createClient({
socket: {
url,
},
});
client.on('error', (err) => console.log('Redis Client Error', err));
(async () => {
await client.connect();
})();
export const pubsub = new RedisPubSub({
publisher: client,
subscriber: client,
});
Unfortunately when running this with the node-redis package it errors with:
Error: Cannot send commands in PubSub mode
The ioredis package works as intended and as shown in the readme.
You need to pass a separate unique instance/client for the subscriber (like the readme shows)