Socket
Socket
Sign inDemoInstall

graphql-ws

Package Overview
Dependencies
Maintainers
2
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-ws - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

12

CHANGELOG.md

@@ -0,1 +1,13 @@

# [4.1.0](https://github.com/enisdenjo/graphql-ws/compare/v4.0.0...v4.1.0) (2021-01-13)
### Bug Fixes
* **server:** `onDisconnect` is called exclusively if the connection is acknowledged ([33ed5f2](https://github.com/enisdenjo/graphql-ws/commit/33ed5f227a787773a6661d4e5efce1be5e500525))
### Features
* **server:** Add `onClose` callback for closures at _any_ point in time ([dd0d4fa](https://github.com/enisdenjo/graphql-ws/commit/dd0d4fa7828974b27876e138c0d09f78b2721d2d))
# [4.0.0](https://github.com/enisdenjo/graphql-ws/compare/v3.2.0...v4.0.0) (2021-01-13)

@@ -2,0 +14,0 @@

30

lib/server.d.ts

@@ -114,12 +114,34 @@ /**

/**
* Called when the socket/client closes/disconnects for
* whatever reason. Provides the close event too. Beware
* that this callback happens AFTER all subscriptions have
* been gracefuly completed.
* Called when the client disconnects for whatever reason after
* he successfully went through the connection initialisation phase.
* Provides the close event too. Beware that this callback happens
* AFTER all subscriptions have been gracefully completed and BEFORE
* the `onClose` callback.
*
* If you are interested in tracking the subscriptions completions,
* consider using the `onComplete` callback.
*
* This callback will be called EXCLUSIVELY if the client connection
* is acknowledged. Meaning, `onConnect` will be called before the `onDisconnect`.
*
* For tracking socket closures at any point in time, regardless
* of the connection state - consider using the `onClose` callback.
*/
onDisconnect?: (ctx: Context<E>, code: number, reason: string) => Promise<void> | void;
/**
* Called when the socket closes for whatever reason, at any
* point in time. Provides the close event too. Beware
* that this callback happens AFTER all subscriptions have
* been gracefully completed and AFTER the `onDisconnect` callback.
*
* If you are interested in tracking the subscriptions completions,
* consider using the `onComplete` callback.
*
* In comparison to `onDisconnect`, this callback will ALWAYS
* be called, regardless if the user succesfully went through
* the connection initialisation or not. `onConnect` might not
* called before the `onClose`.
*/
onClose?: (ctx: Context<E>, code: number, reason: string) => Promise<void> | void;
/**
* The subscribe callback executed right after

@@ -126,0 +148,0 @@ * acknowledging the request before any payload

11

lib/server.js

@@ -29,3 +29,3 @@ "use strict";

const { schema, context, roots, execute, subscribe, connectionInitWaitTimeout = 3 * 1000, // 3 seconds
onConnect, onDisconnect, onSubscribe, onOperation, onNext, onError, onComplete, } = options;
onConnect, onDisconnect, onClose, onSubscribe, onOperation, onNext, onError, onComplete, } = options;
return {

@@ -35,4 +35,5 @@ opened(socket, extra) {

socket.close(1002, 'Protocol Error');
return async () => {
/* nothing was set up */
return async (code, reason) => {
/* nothing was set up, just notify the closure */
await (onClose === null || onClose === void 0 ? void 0 : onClose(ctx, code, reason));
};

@@ -253,3 +254,5 @@ }

}
await (onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect(ctx, code, reason));
if (ctx.acknowledged)
await (onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect(ctx, code, reason));
await (onClose === null || onClose === void 0 ? void 0 : onClose(ctx, code, reason));
};

@@ -256,0 +259,0 @@ },

{
"name": "graphql-ws",
"version": "4.0.0",
"version": "4.1.0",
"description": "Coherent, zero-dependency, lazy, simple, GraphQL over WebSocket Protocol compliant server and client",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc