Skip to content

Commit b657e67

Browse files
authored
Update README.md
1 parent 0fc71e6 commit b657e67

File tree

1 file changed

+34
-3
lines changed

1 file changed

+34
-3
lines changed

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# graphql-redis-subscriptions
22

3-
[![Dependabot badge](https://flat.badgen.net/dependabot/davidyaha/graphql-redis-subscriptions?icon=dependabot)](https://dependabot.com/)
43
[![Build Status](https://travis-ci.org/davidyaha/graphql-redis-subscriptions.svg?branch=master)](https://travis-ci.org/davidyaha/graphql-redis-subscriptions)
54

65
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 = {
109108
}
110109
```
111110

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+
export interface PubSubRedisOptions {
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. |
133+
| `triggerTransform` | `function` | (trigger) => trigger | [deprecated](#using-trigger-transform-deprecated) |
134+
| `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
113144

114145
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.
115146

@@ -133,7 +164,7 @@ const pubsub = new RedisPubSub({
133164
});
134165
```
135166

136-
**Receiving messages as Buffers**
167+
### Receiving messages as Buffers
137168

138169
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:
139170

0 commit comments

Comments
 (0)