@graphql-yoga/redis-event-target 0.1.0-canary-8bcfabb.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js CHANGED
@@ -12,7 +12,7 @@ function createRedisEventTarget(args) {
12
12
  return;
13
13
  }
14
14
  const event = new eventAPI.Event(channel);
15
- event.data = JSON.parse(message);
15
+ event.data = message === '' ? undefined : JSON.parse(message);
16
16
  for (const callback of callbacks) {
17
17
  callback(event);
18
18
  }
@@ -47,7 +47,9 @@ function createRedisEventTarget(args) {
47
47
  addCallback(topic, callback);
48
48
  },
49
49
  dispatchEvent(event) {
50
- publishClient.publish(event.type, JSON.stringify(event.data));
50
+ publishClient.publish(event.type, event.data === undefined
51
+ ? ''
52
+ : JSON.stringify(event.data));
51
53
  return true;
52
54
  },
53
55
  removeEventListener(topic, callbackOrOptions) {
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { resolveGlobalConfig, } from '@graphql-yoga/typed-event-target';
1
+ import { resolveGlobalConfig } from '@graphql-yoga/typed-event-target';
2
2
  export function createRedisEventTarget(args) {
3
3
  const { publishClient, subscribeClient } = args;
4
4
  const eventAPI = resolveGlobalConfig(args.event);
@@ -9,7 +9,7 @@ export function createRedisEventTarget(args) {
9
9
  return;
10
10
  }
11
11
  const event = new eventAPI.Event(channel);
12
- event.data = JSON.parse(message);
12
+ event.data = message === '' ? undefined : JSON.parse(message);
13
13
  for (const callback of callbacks) {
14
14
  callback(event);
15
15
  }
@@ -44,7 +44,9 @@ export function createRedisEventTarget(args) {
44
44
  addCallback(topic, callback);
45
45
  },
46
46
  dispatchEvent(event) {
47
- publishClient.publish(event.type, JSON.stringify(event.data));
47
+ publishClient.publish(event.type, event.data === undefined
48
+ ? ''
49
+ : JSON.stringify(event.data));
48
50
  return true;
49
51
  },
50
52
  removeEventListener(topic, callbackOrOptions) {
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@graphql-yoga/redis-event-target",
3
- "version": "0.1.0-canary-8bcfabb.0",
3
+ "version": "0.1.2",
4
4
  "description": "",
5
5
  "peerDependencies": {
6
6
  "ioredis": "^5.0.6"
7
7
  },
8
8
  "dependencies": {
9
- "@graphql-yoga/typed-event-target": "0.1.0-canary-8bcfabb.0"
9
+ "@graphql-yoga/typed-event-target": "^0.1.0"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { type TypedEventTarget, type EventAPI } from '@graphql-yoga/typed-event-target';
1
+ import type { TypedEventTarget, EventAPI } from '@graphql-yoga/typed-event-target';
2
2
  import type { Redis, Cluster } from 'ioredis';
3
3
  export declare type CreateRedisEventTargetArgs = {
4
4
  publishClient: Redis | Cluster;