@@ -2,12 +2,14 @@ import Redis, { type Cluster } from 'ioredis';
22import RedisMock from 'ioredis-mock' ;
33import { process } from '@graphql-mesh/cross-helpers' ;
44import { stringInterpolator } from '@graphql-mesh/string-interpolation' ;
5- import type {
6- KeyValueCache ,
7- KeyValueCacheSetOptions ,
8- Logger ,
9- MeshPubSub ,
10- YamlConfig ,
5+ import {
6+ toMeshPubSub ,
7+ type HivePubSub ,
8+ type KeyValueCache ,
9+ type KeyValueCacheSetOptions ,
10+ type Logger ,
11+ type MeshPubSub ,
12+ type YamlConfig ,
1113} from '@graphql-mesh/types' ;
1214import { DisposableSymbols } from '@whatwg-node/disposablestack' ;
1315
@@ -18,7 +20,9 @@ function interpolateStrWithEnv(str: string): string {
1820export default class RedisCache < V = string > implements KeyValueCache < V > , Disposable {
1921 private client : Redis | Cluster ;
2022
21- constructor ( options : YamlConfig . Cache [ 'redis' ] & { pubsub ?: MeshPubSub ; logger : Logger } ) {
23+ constructor (
24+ options : YamlConfig . Cache [ 'redis' ] & { pubsub ?: MeshPubSub | HivePubSub ; logger : Logger } ,
25+ ) {
2226 const lazyConnect = options . lazyConnect !== false ;
2327 if ( 'startupNodes' in options ) {
2428 const parsedUsername =
@@ -117,10 +121,11 @@ export default class RedisCache<V = string> implements KeyValueCache<V>, Disposa
117121 this . client = new RedisMock ( ) ;
118122 }
119123 }
124+ const pubsub = toMeshPubSub ( options . pubsub ) ;
120125 // TODO: PubSub.destroy will no longer be needed after v0
121- const id = options . pubsub ?. subscribe ( 'destroy' , ( ) => {
126+ const id = pubsub ?. subscribe ( 'destroy' , ( ) => {
122127 this . client . disconnect ( false ) ;
123- options . pubsub . unsubscribe ( id ) ;
128+ pubsub . unsubscribe ( id ) ;
124129 } ) ;
125130 }
126131
0 commit comments