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

types: allow specifiying enums for allowed triggers

Open rohit-gohri opened this issue 4 years ago • 3 comments

This makes it possible to do something like:

export enum SubscriptionsTopics {
  A,
  B,
};

const redis = new IORedis();

export const graphqlPubsub = new RedisPubSub<SubscriptionsTopics>({
  publisher: redis,
  subscriber: redis,
});

rohit-gohri avatar May 11 '21 06:05 rohit-gohri

Hey @rohit-gohri Thanks for the contribution!

I wouldn't mind merging that but please make sure that CI is passing. At the moment it seems like that typescript compile is breaking.

davidyaha avatar May 15 '21 19:05 davidyaha

Also, if you don't mind, please add a section to the README that demonstrates how this can be used for TS users.

davidyaha avatar May 15 '21 19:05 davidyaha

Hi @davidyaha, sure. I'm still figuring out what the best way to do this would be, was trying to also enforce the types of the payload through a payloadmap type. But couldn't get that working properly.

I guess, I'll leave that part for another PR and just template the topics for now.

rohit-gohri avatar May 17 '21 04:05 rohit-gohri