@graphql-tools/executor-common 0.0.0

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/dist/index.cjs ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var core = require('@envelop/core');
4
+ var utils = require('@graphql-tools/utils');
5
+ var graphql = require('graphql');
6
+
7
+ const defaultPrintFn = utils.memoize1(function defaultPrintFn2(document) {
8
+ return graphql.stripIgnoredCharacters(core.getDocumentString(document, graphql.print));
9
+ });
10
+ function executionRequestToGraphQLParams({
11
+ executionRequest,
12
+ excludeQuery,
13
+ printFn = defaultPrintFn
14
+ }) {
15
+ return {
16
+ query: excludeQuery ? void 0 : printFn(executionRequest.document),
17
+ variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0 ? executionRequest.variables : void 0,
18
+ operationName: executionRequest.operationName ? executionRequest.operationName : void 0,
19
+ extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0 ? executionRequest.extensions : void 0
20
+ };
21
+ }
22
+
23
+ exports.defaultPrintFn = defaultPrintFn;
24
+ exports.executionRequestToGraphQLParams = executionRequestToGraphQLParams;
@@ -0,0 +1,26 @@
1
+ import { ExecutionRequest } from '@graphql-tools/utils';
2
+ import { DocumentNode } from 'graphql';
3
+
4
+ declare const defaultPrintFn: (document: DocumentNode) => string;
5
+ interface ExecutionRequestToGraphQLParams {
6
+ executionRequest: ExecutionRequest;
7
+ excludeQuery?: boolean;
8
+ printFn?: typeof defaultPrintFn;
9
+ }
10
+ interface GraphQLParams {
11
+ query?: string | undefined;
12
+ variables?: Record<string, any>;
13
+ operationName?: string;
14
+ extensions?: Record<string, any>;
15
+ }
16
+ declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
+ excludeQuery: true;
18
+ }): Omit<GraphQLParams, 'query'>;
19
+ declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
+ excludeQuery?: false;
21
+ }): Omit<GraphQLParams, 'query'> & {
22
+ query: string;
23
+ };
24
+ declare function executionRequestToGraphQLParams(opts: ExecutionRequestToGraphQLParams): GraphQLParams;
25
+
26
+ export { type GraphQLParams, defaultPrintFn, executionRequestToGraphQLParams };
@@ -0,0 +1,26 @@
1
+ import { ExecutionRequest } from '@graphql-tools/utils';
2
+ import { DocumentNode } from 'graphql';
3
+
4
+ declare const defaultPrintFn: (document: DocumentNode) => string;
5
+ interface ExecutionRequestToGraphQLParams {
6
+ executionRequest: ExecutionRequest;
7
+ excludeQuery?: boolean;
8
+ printFn?: typeof defaultPrintFn;
9
+ }
10
+ interface GraphQLParams {
11
+ query?: string | undefined;
12
+ variables?: Record<string, any>;
13
+ operationName?: string;
14
+ extensions?: Record<string, any>;
15
+ }
16
+ declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
17
+ excludeQuery: true;
18
+ }): Omit<GraphQLParams, 'query'>;
19
+ declare function executionRequestToGraphQLParams(opts: Omit<ExecutionRequestToGraphQLParams, 'excludeQuery'> & {
20
+ excludeQuery?: false;
21
+ }): Omit<GraphQLParams, 'query'> & {
22
+ query: string;
23
+ };
24
+ declare function executionRequestToGraphQLParams(opts: ExecutionRequestToGraphQLParams): GraphQLParams;
25
+
26
+ export { type GraphQLParams, defaultPrintFn, executionRequestToGraphQLParams };
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ import { getDocumentString } from '@envelop/core';
2
+ import { memoize1 } from '@graphql-tools/utils';
3
+ import { stripIgnoredCharacters, print } from 'graphql';
4
+
5
+ const defaultPrintFn = memoize1(function defaultPrintFn2(document) {
6
+ return stripIgnoredCharacters(getDocumentString(document, print));
7
+ });
8
+ function executionRequestToGraphQLParams({
9
+ executionRequest,
10
+ excludeQuery,
11
+ printFn = defaultPrintFn
12
+ }) {
13
+ return {
14
+ query: excludeQuery ? void 0 : printFn(executionRequest.document),
15
+ variables: (executionRequest.variables && Object.keys(executionRequest.variables).length) > 0 ? executionRequest.variables : void 0,
16
+ operationName: executionRequest.operationName ? executionRequest.operationName : void 0,
17
+ extensions: executionRequest.extensions && Object.keys(executionRequest.extensions).length > 0 ? executionRequest.extensions : void 0
18
+ };
19
+ }
20
+
21
+ export { defaultPrintFn, executionRequestToGraphQLParams };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@graphql-tools/executor-common",
3
+ "version": "0.0.0",
4
+ "type": "module",
5
+ "description": "A set of utils for faster development of GraphQL tools",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/graphql-hive/gateway.git",
9
+ "directory": "packages/executors/graphql-ws"
10
+ },
11
+ "author": "Arda TANRIKULU <ardatanrikulu@gmail.com>",
12
+ "license": "MIT",
13
+ "engines": {
14
+ "node": ">=18.0.0"
15
+ },
16
+ "main": "./dist/index.js",
17
+ "exports": {
18
+ ".": {
19
+ "require": {
20
+ "types": "./dist/index.d.cts",
21
+ "default": "./dist/index.cjs"
22
+ },
23
+ "import": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "./package.json": "./package.json"
29
+ },
30
+ "types": "./dist/index.d.ts",
31
+ "files": [
32
+ "dist"
33
+ ],
34
+ "scripts": {
35
+ "build": "pkgroll --clean-dist",
36
+ "prepack": "yarn build"
37
+ },
38
+ "peerDependencies": {
39
+ "graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
40
+ },
41
+ "dependencies": {
42
+ "@envelop/core": "^5.0.2",
43
+ "@graphql-tools/utils": "^10.7.0"
44
+ },
45
+ "devDependencies": {
46
+ "graphql": "^16.9.0",
47
+ "pkgroll": "2.6.0"
48
+ },
49
+ "sideEffects": false
50
+ }