You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This package implements the PubSubEngine Interface from the [graphql-subscriptions](https://github.com/apollographql/graphql-subscriptions) package and also the new AsyncIterator interface.
@@ -109,7 +108,39 @@ export const resolvers = {
109
108
}
110
109
```
111
110
112
-
## Creating the Redis Client
111
+
## Configuring RedisPubSub
112
+
113
+
`RedisPubSub` constructor can be passed a configuration object to enable some advanced features.
114
+
115
+
```ts
116
+
exportinterfacePubSubRedisOptions {
117
+
connection?:RedisOptions|string;
118
+
triggerTransform?:TriggerTransform;
119
+
connectionListener?: (err?:Error) =>void;
120
+
publisher?:RedisClient;
121
+
subscriber?:RedisClient;
122
+
reviver?:Reviver;
123
+
serializer?:Serializer;
124
+
deserializer?:Deserializer;
125
+
messageEventName?:string;
126
+
pmessageEventName?:string;
127
+
}
128
+
```
129
+
130
+
| option | type | default | description |
131
+
| ------ | ---- | ------- | ----------- |
132
+
|`connection`|[`object \| string`](https://github.com/luin/ioredis#connect-to-redis)|`undefined`| the connection option is passed as is to the `ioredis` constructor to create redis subscriber and publisher instances. for greater controll, use `publisher` and `subscriber` options. |
|`connectionListener`|`function`|`undefined`| pass in connection listener to log errors or make sure connection to redis instance was created successfully. |
135
+
|`publisher`|`function`|`undefined`| must be passed along side `subscriber`. see [#creating-a-redis-client](#creating-a-redis-client)|
136
+
|`subscriber`|`function`|`undefined`| must be passed along side `publisher`. see [#creating-a-redis-client](#creating-a-redis-client)|
137
+
|`reviver`|`function`|`undefined`| see [#using-a-custom-reviver](#using-a-custom-reviver)|
138
+
|`serializer`|`function`|`undefined`| see [#using-a-custom-serializerdeserializer](#using-a-custom-serializerdeserializer)|
139
+
|`deserializer`|`function`|`undefined`| see [#using-a-custom-serializerdeserializer](#using-a-custom-serializerdeserializer)|
140
+
|`messageEventName`|`string`|`undefined`| see [#receiving-messages-as-buffers](#receiving-messages-as-buffers)|
141
+
|`pmessageEventName`|`string`|`undefined`| see [#receiving-messages-as-buffers](#receiving-messages-as-buffers)|
142
+
143
+
## Creating a Redis Client
113
144
114
145
The basic usage is great for development and you will be able to connect to a Redis server running on your system seamlessly. For production usage, it is recommended to pass a redis client (like ioredis) to the RedisPubSub constructor. This way you can control all the options of your redis connection, for example the connection retry strategy.
115
146
@@ -133,7 +164,7 @@ const pubsub = new RedisPubSub({
133
164
});
134
165
```
135
166
136
-
**Receiving messages as Buffers**
167
+
### Receiving messages as Buffers
137
168
138
169
Some Redis use cases require receiving binary-safe data back from redis (in a Buffer). To accomplish this, override the event names for receiving messages and pmessages. Different redis clients use different names, for example:
0 commit comments