@graphql-tools/executor-graphql-ws
Advanced tools
Comparing version 1.2.0-rc-20240705094201-3bac867cbb5dc177281e14fbdbfa80f1f73301af to 1.2.0-rc-20240705111326-d20220e5785e6513e3a48afc07ecee8157ce2ea7
@@ -9,2 +9,3 @@ "use strict"; | ||
const utils_1 = require("@graphql-tools/utils"); | ||
const defaultPrintFn = (0, utils_1.memoize1)(graphql_1.print); | ||
function isClient(client) { | ||
@@ -16,2 +17,3 @@ return 'subscribe' in client; | ||
let executorConnectionParams = {}; | ||
let printFn = defaultPrintFn; | ||
if (isClient(clientOptionsOrClient)) { | ||
@@ -21,2 +23,5 @@ graphqlWSClient = clientOptionsOrClient; | ||
else { | ||
if (clientOptionsOrClient.print) { | ||
printFn = clientOptionsOrClient.print; | ||
} | ||
graphqlWSClient = (0, graphql_ws_1.createClient)({ | ||
@@ -44,3 +49,3 @@ ...clientOptionsOrClient, | ||
} | ||
const query = (0, graphql_1.print)(document); | ||
const query = printFn(document); | ||
const iterableIterator = graphqlWSClient.iterate({ | ||
@@ -57,7 +62,8 @@ query, | ||
}; | ||
executor[Symbol.asyncDispose] = function disposeWS() { | ||
const disposableExecutor = executor; | ||
disposableExecutor[Symbol.asyncDispose] = function disposeWS() { | ||
return graphqlWSClient.dispose(); | ||
}; | ||
return executor; | ||
return disposableExecutor; | ||
} | ||
exports.buildGraphQLWSExecutor = buildGraphQLWSExecutor; |
import { print } from 'graphql'; | ||
import { createClient } from 'graphql-ws'; | ||
import WebSocket from 'isomorphic-ws'; | ||
import { getOperationASTFromRequest, } from '@graphql-tools/utils'; | ||
import { getOperationASTFromRequest, memoize1, } from '@graphql-tools/utils'; | ||
const defaultPrintFn = memoize1(print); | ||
function isClient(client) { | ||
@@ -11,2 +12,3 @@ return 'subscribe' in client; | ||
let executorConnectionParams = {}; | ||
let printFn = defaultPrintFn; | ||
if (isClient(clientOptionsOrClient)) { | ||
@@ -16,2 +18,5 @@ graphqlWSClient = clientOptionsOrClient; | ||
else { | ||
if (clientOptionsOrClient.print) { | ||
printFn = clientOptionsOrClient.print; | ||
} | ||
graphqlWSClient = createClient({ | ||
@@ -39,3 +44,3 @@ ...clientOptionsOrClient, | ||
} | ||
const query = print(document); | ||
const query = printFn(document); | ||
const iterableIterator = graphqlWSClient.iterate({ | ||
@@ -52,6 +57,7 @@ query, | ||
}; | ||
executor[Symbol.asyncDispose] = function disposeWS() { | ||
const disposableExecutor = executor; | ||
disposableExecutor[Symbol.asyncDispose] = function disposeWS() { | ||
return graphqlWSClient.dispose(); | ||
}; | ||
return executor; | ||
return disposableExecutor; | ||
} |
{ | ||
"name": "@graphql-tools/executor-graphql-ws", | ||
"version": "1.2.0-rc-20240705094201-3bac867cbb5dc177281e14fbdbfa80f1f73301af", | ||
"version": "1.2.0-rc-20240705111326-d20220e5785e6513e3a48afc07ecee8157ce2ea7", | ||
"description": "A set of utils for faster development of GraphQL tools", | ||
@@ -10,3 +10,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@graphql-tools/utils": "10.3.0-rc-20240705094201-3bac867cbb5dc177281e14fbdbfa80f1f73301af", | ||
"@graphql-tools/utils": "10.3.0-rc-20240705111326-d20220e5785e6513e3a48afc07ecee8157ce2ea7", | ||
"@types/ws": "^8.0.0", | ||
@@ -13,0 +13,0 @@ "graphql-ws": "^5.14.0", |
@@ -0,1 +1,2 @@ | ||
import { print } from 'graphql'; | ||
import { Client, ClientOptions } from 'graphql-ws'; | ||
@@ -5,4 +6,5 @@ import { DisposableExecutor } from '@graphql-tools/utils'; | ||
onClient?: (client: Client) => void; | ||
print?: typeof print; | ||
} | ||
export declare function buildGraphQLWSExecutor(clientOptionsOrClient: GraphQLWSExecutorOptions | Client): DisposableExecutor; | ||
export {}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8031
132
+ Added@graphql-tools/utils@10.3.0-rc-20240705111326-d20220e5785e6513e3a48afc07ecee8157ce2ea7(transitive)
- Removed@graphql-tools/utils@10.3.0-rc-20240705094201-3bac867cbb5dc177281e14fbdbfa80f1f73301af(transitive)
Updated@graphql-tools/utils@10.3.0-rc-20240705111326-d20220e5785e6513e3a48afc07ecee8157ce2ea7