graphql-redis-subscriptions icon indicating copy to clipboard operation
graphql-redis-subscriptions copied to clipboard

node-redis package not compatible

Open Darkbladecr opened this issue 4 years ago • 1 comments
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.

Darkbladecr avatar Oct 14 '21 22:10 Darkbladecr

You need to pass a separate unique instance/client for the subscriber (like the readme shows)

andrhamm avatar Jul 09 '22 02:07 andrhamm