@graphql-tools/executor-graphql-ws 0.0.1-alpha-20221108142800-3beb5fe2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildGraphQLWSExecutor = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const repeater_1 = require("@repeaterjs/repeater");
6
+ const graphql_1 = require("graphql");
7
+ const graphql_ws_1 = require("graphql-ws");
8
+ const isomorphic_ws_1 = tslib_1.__importDefault(require("isomorphic-ws"));
9
+ function buildGraphQLWSExecutor(url, webSocketImpl = isomorphic_ws_1.default, connectionParams) {
10
+ const graphqlWSClient = (0, graphql_ws_1.createClient)({
11
+ url,
12
+ webSocketImpl,
13
+ connectionParams,
14
+ lazy: true,
15
+ });
16
+ return function GraphQLWSExecutor({ document, variables, operationName, extensions, }) {
17
+ const query = (0, graphql_1.print)(document);
18
+ return new repeater_1.Repeater(function repeaterExecutor(push, stop) {
19
+ const unsubscribe = graphqlWSClient.subscribe({
20
+ query,
21
+ variables,
22
+ operationName,
23
+ extensions,
24
+ }, {
25
+ next(data) {
26
+ return push(data);
27
+ },
28
+ error(error) {
29
+ return stop(error);
30
+ },
31
+ complete() {
32
+ return stop();
33
+ },
34
+ });
35
+ return stop.finally(unsubscribe);
36
+ });
37
+ };
38
+ }
39
+ exports.buildGraphQLWSExecutor = buildGraphQLWSExecutor;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/esm/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import { Repeater } from '@repeaterjs/repeater';
2
+ import { print } from 'graphql';
3
+ import { createClient } from 'graphql-ws';
4
+ import WebSocket from 'isomorphic-ws';
5
+ export function buildGraphQLWSExecutor(url, webSocketImpl = WebSocket, connectionParams) {
6
+ const graphqlWSClient = createClient({
7
+ url,
8
+ webSocketImpl,
9
+ connectionParams,
10
+ lazy: true,
11
+ });
12
+ return function GraphQLWSExecutor({ document, variables, operationName, extensions, }) {
13
+ const query = print(document);
14
+ return new Repeater(function repeaterExecutor(push, stop) {
15
+ const unsubscribe = graphqlWSClient.subscribe({
16
+ query,
17
+ variables,
18
+ operationName,
19
+ extensions,
20
+ }, {
21
+ next(data) {
22
+ return push(data);
23
+ },
24
+ error(error) {
25
+ return stop(error);
26
+ },
27
+ complete() {
28
+ return stop();
29
+ },
30
+ });
31
+ return stop.finally(unsubscribe);
32
+ });
33
+ };
34
+ }
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@graphql-tools/executor-graphql-ws",
3
+ "version": "0.0.1-alpha-20221108142800-3beb5fe2",
4
+ "description": "A set of utils for faster development of GraphQL tools",
5
+ "sideEffects": false,
6
+ "peerDependencies": {
7
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
8
+ },
9
+ "dependencies": {
10
+ "@types/ws": "^8.0.0",
11
+ "@graphql-tools/utils": "9.1.0",
12
+ "@repeaterjs/repeater": "3.0.4",
13
+ "graphql-ws": "5.11.2",
14
+ "isomorphic-ws": "5.0.0",
15
+ "ws": "8.11.0"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "ardatan/graphql-tools",
20
+ "directory": "packages/executors/graphql-ws"
21
+ },
22
+ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
23
+ "license": "MIT",
24
+ "main": "cjs/index.js",
25
+ "module": "esm/index.js",
26
+ "typings": "typings/index.d.ts",
27
+ "typescript": {
28
+ "definition": "typings/index.d.ts"
29
+ },
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "require": {
34
+ "types": "./typings/index.d.cts",
35
+ "default": "./cjs/index.js"
36
+ },
37
+ "import": {
38
+ "types": "./typings/index.d.ts",
39
+ "default": "./esm/index.js"
40
+ },
41
+ "default": {
42
+ "types": "./typings/index.d.ts",
43
+ "default": "./esm/index.js"
44
+ }
45
+ },
46
+ "./*": {
47
+ "require": {
48
+ "types": "./typings/*.d.cts",
49
+ "default": "./cjs/*.js"
50
+ },
51
+ "import": {
52
+ "types": "./typings/*.d.ts",
53
+ "default": "./esm/*.js"
54
+ },
55
+ "default": {
56
+ "types": "./typings/*.d.ts",
57
+ "default": "./esm/*.js"
58
+ }
59
+ },
60
+ "./package.json": "./package.json"
61
+ }
62
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="ws" />
2
+ import { Executor } from '@graphql-tools/utils';
3
+ import WebSocket from 'isomorphic-ws';
4
+ export declare function buildGraphQLWSExecutor(url: string, webSocketImpl?: typeof WebSocket, connectionParams?: Record<string, any>): Executor;
@@ -0,0 +1,4 @@
1
+ /// <reference types="ws" />
2
+ import { Executor } from '@graphql-tools/utils';
3
+ import WebSocket from 'isomorphic-ws';
4
+ export declare function buildGraphQLWSExecutor(url: string, webSocketImpl?: typeof WebSocket, connectionParams?: Record<string, any>): Executor;