I'm using the code-first approach with subscriptions + redis pubsub, been trying to find some docs on how to disconnect the user if there's a certain event published for that channel.
This is how my code looks currently:
@Subscription(() => SyncEvent, {
resolve: (value: SyncEvent) => {
....
public async syncEvents(
@CurrentSession() session: IAccessToken
): Promise<AsyncIterator<SyncEvent>> {
// checking if a device is attached to the session so we can throw if not
if (!session.deviceId) {
throw new IntentionalException(ExceptionEnum.Events['000'], 'NOT_FOUND');
}
// returning the async interator
return this.pubSubService.pubSub.asyncIterator(session.deviceId);
}
Using this bit:
graphql-redis-subscriptions
Where pubSub comes from @Inject('PUB_SUB') public readonly pubSub: RedisPubSub, RedisPubSub coming from that package above