From e2e5e0482a73659f068037e0dd9920e20b96e27d Mon Sep 17 00:00:00 2001 From: Tiago Costa Date: Thu, 6 Jul 2017 16:01:14 +0100 Subject: [PATCH] feat(NA): expose opId onOperationComplete. --- CHANGELOG.md | 1 + README.md | 2 +- src/server.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0a18baaf..8d4df323c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Changelog ### vNEXT +- Expose opId `onOperationComplete` method [PR #211](https://github.com/apollographql/subscriptions-transport-ws/pull/211) ### 0.7.3 - Fix for first subscription is never unsubscribed [PR #179](https://github.com/apollographql/subscriptions-transport-ws/pull/179) diff --git a/README.md b/README.md index 83a19b610..16cd42766 100644 --- a/README.md +++ b/README.md @@ -316,7 +316,7 @@ A quick way to add the `subscribe` and `unsubscribe` functions to the [network i * `execute?: (schema, document, rootValue, contextValue, variableValues, operationName) => Promise | AsyncIterator` : GraphQL `execute` function, provide the default one from `graphql` package. Return value of `AsyncItrator` is also valid since this package also support reactive `execute` methods. * `subscribe?: (schema, document, rootValue, contextValue, variableValues, operationName) => AsyncIterator` : GraphQL `subscribe` function, provide the default one from `graphql` package. * `onOperation?: (message: SubscribeMessage, params: SubscriptionOptions, webSocket: WebSocket)` : optional method to create custom params that will be used when resolving this operation - * `onOperationComplete?: (webSocket: WebSocket)` : optional method that called when a GraphQL operation is done (for query and mutation it's immeditaly, and for subscriptions when unsubscribing) + * `onOperationComplete?: (webSocket: WebSocket, opId: string)` : optional method that called when a GraphQL operation is done (for query and mutation it's immeditaly, and for subscriptions when unsubscribing) * `onConnect?: (connectionParams: Object, webSocket: WebSocket)` : optional method that called when a client connects to the socket, called with the `connectionParams` from the client, if the return value is an object, its elements will be added to the context. return `false` or throw an exception to reject the connection. May return a Promise. * `onDisconnect?: (webSocket: WebSocket)` : optional method that called when a client disconnects * `keepAlive?: number` : optional interval in ms to send `KEEPALIVE` messages to all clients diff --git a/src/server.ts b/src/server.ts index eda235768..f0642d49f 100644 --- a/src/server.ts +++ b/src/server.ts @@ -222,7 +222,7 @@ export class SubscriptionServer { delete connectionContext.operations[opId]; if (this.onOperationComplete) { - this.onOperationComplete(connectionContext.socket); + this.onOperationComplete(connectionContext.socket, opId); } } }