Socket
Socket
Sign inDemoInstall

graphql-ws

Package Overview
Dependencies
1
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.15.0 to 5.16.0

6

lib/server.d.ts

@@ -159,3 +159,3 @@ /**

*/
onDisconnect?: (ctx: Context<P, E>, code: number, reason: string) => Promise<void> | void;
onDisconnect?: (ctx: Context<P, E>, code?: number, reason?: string) => Promise<void> | void;
/**

@@ -175,3 +175,3 @@ * Called when the socket closes for whatever reason, at any

*/
onClose?: (ctx: Context<P, E>, code: number, reason: string) => Promise<void> | void;
onClose?: (ctx: Context<P, E>, code?: number, reason?: string) => Promise<void> | void;
/**

@@ -300,3 +300,3 @@ * The subscribe callback executed right after

*/
opened(socket: WebSocket, ctxExtra: E): (code: number, reason: string) => Promise<void>;
opened(socket: WebSocket, ctxExtra: E): (code?: number, reason?: string) => Promise<void>;
}

@@ -303,0 +303,0 @@ /** @category Server */

@@ -152,3 +152,5 @@ "use strict";

if ((0, utils_1.areGraphQLErrors)(maybeExecArgsOrErrors))
return await emit.error(maybeExecArgsOrErrors);
return id in ctx.subscriptions
? await emit.error(maybeExecArgsOrErrors)
: void 0;
else if (Array.isArray(maybeExecArgsOrErrors))

@@ -174,9 +176,13 @@ throw new Error('Invalid return value from onSubscribe hook, expected an array of GraphQLError objects');

if (validationErrors.length > 0)
return await emit.error(validationErrors);
return id in ctx.subscriptions
? await emit.error(validationErrors)
: void 0;
}
const operationAST = (0, graphql_1.getOperationAST)(execArgs.document, execArgs.operationName);
if (!operationAST)
return await emit.error([
new graphql_1.GraphQLError('Unable to identify operation'),
]);
return id in ctx.subscriptions
? await emit.error([
new graphql_1.GraphQLError('Unable to identify operation'),
])
: void 0;
// if `onSubscribe` didn't specify a rootValue, inject one

@@ -260,7 +266,9 @@ if (!('rootValue' in execArgs))

clearTimeout(connectionInitWait);
for (const [id, sub] of Object.entries(ctx.subscriptions)) {
if ((0, utils_1.isAsyncGenerator)(sub))
await sub.return(undefined);
delete ctx.subscriptions[id]; // deleting the subscription means no further activity should take place
}
const subs = Object.assign({}, ctx.subscriptions);
// @ts-expect-error: I can write
ctx.subscriptions = {}; // deleting the subscription means no further activity should take place
// we return all iterable subscriptions immediatelly, independant of the order
await Promise.all(Object.values(subs)
.filter(utils_1.isAsyncGenerator)
.map((sub) => sub.return(undefined)));
if (ctx.acknowledged)

@@ -267,0 +275,0 @@ await (onDisconnect === null || onDisconnect === void 0 ? void 0 : onDisconnect(ctx, code, reason));

{
"name": "graphql-ws",
"version": "5.15.0",
"version": "5.16.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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc