Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switch to graphql-subscriptions-continued for proper typing #608

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
ports:
- 6379:6379
redis-cluster:
image: grokzen/redis-cluster:latest
image: grokzen/redis-cluster:7.0.10
ports:
- 7006:7000
- 7001:7001
Expand Down
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"chai-as-promised": "^7.1.1",
"eslint": "^8.23.0",
"graphql": "^15.7.2",
"graphql-subscriptions": "^2.0.0",
"graphql-subscriptions-continued": "^3.0.0",
"ioredis": "^5.2.4",
"mocha": "^10.0.0",
"nyc": "^15.1.0",
Expand Down
114 changes: 0 additions & 114 deletions src/pubsub-async-iterator.ts

This file was deleted.

11 changes: 6 additions & 5 deletions src/redis-pubsub.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {Cluster, Redis, RedisOptions} from 'ioredis';
import {PubSubEngine} from 'graphql-subscriptions';
import {PubSubAsyncIterator} from './pubsub-async-iterator';
import {PubSubEngine, PubSubAsyncIterableIterator} from 'graphql-subscriptions-continued';

type RedisClient = Redis | Cluster;
type OnMessage<T> = (message: T) => void;
Expand All @@ -19,9 +18,11 @@ export interface PubSubRedisOptions {
pmessageEventName?: string;
}

export class RedisPubSub implements PubSubEngine {
export class RedisPubSub extends PubSubEngine {

constructor(options: PubSubRedisOptions = {}) {
super();

const {
triggerTransform,
connection,
Expand Down Expand Up @@ -139,8 +140,8 @@ export class RedisPubSub implements PubSubEngine {
delete this.subscriptionMap[subId];
}

public asyncIterator<T>(triggers: string | string[], options?: unknown): AsyncIterator<T> {
return new PubSubAsyncIterator<T>(this, triggers, options);
public asyncIterator<T>(triggers: string | string[], options?: unknown) {
return new PubSubAsyncIterableIterator<T>(this, triggers, options);
}

public getSubscriber(): RedisClient {
Expand Down
6 changes: 3 additions & 3 deletions src/test/integration-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ function buildSchema(iterator, patternIterator) {
fields: {
testSubscription: {
type: GraphQLString,
subscribe: withFilter(() => iterator, () => true) as GraphQLFieldResolver<any, any, any>,
subscribe: withFilter(() => iterator, () => true),
resolve: root => {
return 'FIRST_EVENT';
},
},

testPatternSubscription: {
type: GraphQLString,
subscribe: withFilter(() => patternIterator, () => true) as GraphQLFieldResolver<any, any, any>,
subscribe: withFilter(() => patternIterator, () => true),
resolve: root => {
return 'SECOND_EVENT';
},
Expand Down Expand Up @@ -148,5 +148,5 @@ describe('PubSubCluster', () => {
pubsub.subscribe<{fire: boolean, from: string}>(eventKey, (data) => {
expect(data).to.contains({ fired: true, from: 'cluster' });
});
}).timeout(2000);
}).timeout(5000);
});