@@ -5,6 +5,10 @@ const redis = require("redis"),
5
5
util = require ( "util" ) ,
6
6
ResultSet = require ( "./resultSet" ) ;
7
7
8
+ /**
9
+ * @typedef {import('ioredis') | redis.RedisClient } RedisClient
10
+ */
11
+
8
12
/**
9
13
* RedisGraph client
10
14
*/
@@ -14,7 +18,7 @@ class Graph {
14
18
* See: node_redis for more options on createClient
15
19
*
16
20
* @param {string } graphId the graph id
17
- * @param {string | redis. RedisClient } [host] Redis host or node_redis client
21
+ * @param {string | RedisClient } [host] Redis host or node_redis client or ioredis client
18
22
* @param {string | number } [port] Redis port (integer)
19
23
* @param {Object } [options] node_redis options
20
24
*/
@@ -29,7 +33,7 @@ class Graph {
29
33
this . _relationshipPromise = undefined ; // used as a synchronization mechanizom for relationship types retrival
30
34
31
35
this . _client =
32
- host instanceof redis . RedisClient
36
+ host && typeof host . send_command === 'function' // check if it's an instance of `redis` or `ioredis`
33
37
? host
34
38
: redis . createClient ( port , host , options ) ;
35
39
this . _sendCommand = util . promisify ( this . _client . send_command ) . bind ( this . _client ) ;
0 commit comments