diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ef022ac7..9dfec889d 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) - Fix to make library able to be installed from a branch [PR #208](https://github.com/apollographql/subscriptions-transport-ws/pull/208) - Fix for non forced closes (now it wont send connection_terminate) [PR #197](https://github.com/apollographql/subscriptions-transport-ws/pull/197) - A lot of connection's flow improvements (on connect, on disconnect and on reconnect) [PR #197](https://github.com/apollographql/subscriptions-transport-ws/pull/197) diff --git a/README.md b/README.md index a3c0162ae..9b3175a8a 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); } } }