diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ac1f2057..61c6c10df 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog
+## v0.11.0 (2021-11-02)
+
+- Support for `graphql@16` and bump minimal supported version to be `graphql@15.7.2`. As part of this change signatures for `ExecuteFunction` and `SubscribeFunction` were changed.
+ [@IvanGoncharov](https://github.com/IvanGoncharov) in [#902](https://github.com/apollographql/subscriptions-transport-ws/pull/902)
+
+
## v0.10.0 (2021-06-08)
- Same contents as v0.9.19 (published before v0.9.19 before realizing it would be helpful if the new version was picked up by packages looking for `^0.9`).
diff --git a/package.json b/package.json
index e3f1abc94..48c13c939 100644
--- a/package.json
+++ b/package.json
@@ -30,11 +30,10 @@
"prepublishOnly": "npm run clean && npm run compile && npm run browser-compile"
},
"peerDependencies": {
- "graphql": ">=0.10.0"
+ "graphql": "^15.7.2 || ^16.0.0"
},
"devDependencies": {
"@types/chai": "^4.0.0",
- "@types/graphql": "^14.0.0",
"@types/is-promise": "^2.1.0",
"@types/lodash": "^4.14.109",
"@types/mocha": "^5.2.5",
@@ -42,7 +41,7 @@
"@types/sinon": "^5.0.1",
"@types/ws": "^5.1.2",
"chai": "^4.0.2",
- "graphql": "^15.3.0",
+ "graphql": "16.0.0",
"graphql-subscriptions": "^1.0.0",
"istanbul": "^1.0.0-alpha.2",
"lodash": "^4.17.1",
@@ -52,7 +51,7 @@
"rimraf": "^2.6.1",
"sinon": "^6.1.4",
"tslint": "^5.10.0",
- "typescript": "^3.9.6",
+ "typescript": "^4.1.0",
"webpack": "^3.1.0"
},
"typings": "dist/index.d.ts",
diff --git a/src/server.ts b/src/server.ts
index fb7c6775b..9be5701f2 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -12,6 +12,8 @@ import {
ValidationContext,
specifiedRules,
GraphQLFieldResolver,
+ ExecutionArgs,
+ SubscriptionArgs,
} from 'graphql';
import { createEmptyIterable } from './utils/empty-iterable';
import { createAsyncIterator, forAwaitEach, isAsyncIterable } from 'iterall';
@@ -55,27 +57,14 @@ export interface OperationMessage {
type: string;
}
-export type ExecuteFunction = (schema: GraphQLSchema,
- document: DocumentNode,
- rootValue?: any,
- contextValue?: any,
- variableValues?: { [key: string]: any },
- operationName?: string,
- fieldResolver?: GraphQLFieldResolver) =>
- ExecutionResult |
- Promise |
- AsyncIterator;
-
-export type SubscribeFunction = (schema: GraphQLSchema,
- document: DocumentNode,
- rootValue?: any,
- contextValue?: any,
- variableValues?: { [key: string]: any },
- operationName?: string,
- fieldResolver?: GraphQLFieldResolver,
- subscribeFieldResolver?: GraphQLFieldResolver) =>
- AsyncIterator |
- Promise | ExecutionResult>;
+export type ExecuteFunction = (args: ExecutionArgs) =>
+ | ExecutionResult
+ | Promise
+ | AsyncIterator;
+
+export type SubscribeFunction = (args: SubscriptionArgs) =>
+ | AsyncIterator
+ | Promise | ExecutionResult>;
export interface ServerOptions {
rootValue?: any;
@@ -356,12 +345,16 @@ export class SubscriptionServer {
if (this.subscribe && isASubscriptionOperation(document, params.operationName)) {
executor = this.subscribe;
}
- executionPromise = Promise.resolve(executor(params.schema,
- document,
- this.rootValue,
- params.context,
- params.variables,
- params.operationName));
+ executionPromise = Promise.resolve(
+ executor({
+ schema: params.schema,
+ document,
+ rootValue: this.rootValue,
+ contextValue: params.context,
+ variableValues: params.variables,
+ operationName: params.operationName,
+ }),
+ );
}
return executionPromise.then((executionResult) => ({
diff --git a/src/test/tests.ts b/src/test/tests.ts
index 2196e1e63..d04a959f8 100644
--- a/src/test/tests.ts
+++ b/src/test/tests.ts
@@ -792,7 +792,7 @@ describe('Client', function () {
try {
sub.unsubscribe();
expect(Object.keys(client.operations).length).to.equals(0);
- resolve();
+ resolve(undefined);
} catch (e) {
reject(e);
}
@@ -2643,7 +2643,7 @@ describe('Client<->Server Flow', () => {
assert(sRes.errors === undefined, 'unexpected error from 1st subscription');
assert(sRes.data, 'unexpected null from 1st subscription result');
expect(Object.keys(client['operations']).length).to.eq(1);
- expect(sRes.data.user.id).to.eq('3');
+ expect(sRes.data.user).to.include({ id: '3' });
firstSubscriptionSpy();
firstSub.unsubscribe();
@@ -2660,7 +2660,7 @@ describe('Client<->Server Flow', () => {
next: (s2Res) => {
assert(s2Res.errors === undefined, 'unexpected error from 2nd subscription');
assert(s2Res.data !== null, 'unexpected null from 2nd subscription result');
- expect(s2Res.data.user.id).to.eq('1');
+ expect(s2Res.data.user).to.include({ id: '1' });
expect(Object.keys(client['operations']).length).to.eq(1);
expect(firstSubscriptionSpy.callCount).to.eq(1);