@graphql-tools/batch-execute 8.5.2-alpha-e7752ba5.0 → 8.5.2-alpha-b9e4a92b.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/cjs/mergeRequests.js +1 -1
- package/cjs/splitResult.js +1 -1
- package/esm/mergeRequests.js +1 -1
- package/esm/splitResult.js +1 -1
- package/package.json +8 -6
- package/typings/createBatchingExecutor.d.cts +3 -0
- package/typings/getBatchingExecutor.d.cts +3 -0
- package/typings/index.d.cts +2 -0
- package/typings/mergeRequests.d.cts +36 -0
- package/typings/prefix.d.cts +5 -0
- package/typings/splitResult.d.cts +5 -0
- package/typings/splitResult.d.ts +1 -1
package/cjs/mergeRequests.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.mergeRequests = void 0;
|
|
5
|
-
const graphql_1 = require("
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
6
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
7
|
const prefix_js_1 = require("./prefix.js");
|
|
8
8
|
/**
|
package/cjs/splitResult.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.splitResult = void 0;
|
|
5
|
-
const graphql_1 = require("
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
6
|
const utils_1 = require("@graphql-tools/utils");
|
|
7
7
|
const prefix_js_1 = require("./prefix.js");
|
|
8
8
|
/**
|
package/esm/mergeRequests.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
|
|
2
|
-
import { visit, Kind, } from '
|
|
2
|
+
import { visit, Kind, } from 'graphql';
|
|
3
3
|
import { getOperationASTFromRequest } from '@graphql-tools/utils';
|
|
4
4
|
import { createPrefix } from './prefix.js';
|
|
5
5
|
/**
|
package/esm/splitResult.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// adapted from https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-source-graphql/src/batching/merge-queries.js
|
|
2
|
-
import { GraphQLError } from '
|
|
2
|
+
import { GraphQLError } from 'graphql';
|
|
3
3
|
import { relocatedError } from '@graphql-tools/utils';
|
|
4
4
|
import { parseKey } from './prefix.js';
|
|
5
5
|
/**
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/batch-execute",
|
|
3
|
-
"version": "8.5.2-alpha-
|
|
3
|
+
"version": "8.5.2-alpha-b9e4a92b.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
7
|
-
"@graphql-tools/utils": "8.9.1-alpha-
|
|
10
|
+
"@graphql-tools/utils": "8.9.1-alpha-b9e4a92b.0",
|
|
8
11
|
"dataloader": "2.1.0",
|
|
9
12
|
"tslib": "^2.4.0",
|
|
10
|
-
"value-or-promise": "1.0.11"
|
|
11
|
-
"@graphql-tools/graphql": "0.1.0-alpha-e7752ba5.0"
|
|
13
|
+
"value-or-promise": "1.0.11"
|
|
12
14
|
},
|
|
13
15
|
"repository": {
|
|
14
16
|
"type": "git",
|
|
@@ -26,7 +28,7 @@
|
|
|
26
28
|
"exports": {
|
|
27
29
|
".": {
|
|
28
30
|
"require": {
|
|
29
|
-
"types": "./typings/index.d.
|
|
31
|
+
"types": "./typings/index.d.cts",
|
|
30
32
|
"default": "./cjs/index.js"
|
|
31
33
|
},
|
|
32
34
|
"import": {
|
|
@@ -40,7 +42,7 @@
|
|
|
40
42
|
},
|
|
41
43
|
"./*": {
|
|
42
44
|
"require": {
|
|
43
|
-
"types": "./typings/*.d.
|
|
45
|
+
"types": "./typings/*.d.cts",
|
|
44
46
|
"default": "./cjs/*.js"
|
|
45
47
|
},
|
|
46
48
|
"import": {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import { Executor, ExecutionRequest } from '@graphql-tools/utils';
|
|
3
|
+
export declare function createBatchingExecutor(executor: Executor, dataLoaderOptions?: DataLoader.Options<any, any, any>, extensionsReducer?: (mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>): Executor;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import DataLoader from 'dataloader';
|
|
2
|
+
import { ExecutionRequest, Executor } from '@graphql-tools/utils';
|
|
3
|
+
export declare const getBatchingExecutor: (_context: Record<string, any>, executor: Executor, dataLoaderOptions?: DataLoader.Options<any, any, any> | undefined, extensionsReducer?: ((mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>) | undefined) => Executor;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Merge multiple queries into a single query in such a way that query results
|
|
4
|
+
* can be split and transformed as if they were obtained by running original queries.
|
|
5
|
+
*
|
|
6
|
+
* Merging algorithm involves several transformations:
|
|
7
|
+
* 1. Replace top-level fragment spreads with inline fragments (... on Query {})
|
|
8
|
+
* 2. Add unique aliases to all top-level query fields (including those on inline fragments)
|
|
9
|
+
* 3. Prefix all variable definitions and variable usages
|
|
10
|
+
* 4. Prefix names (and spreads) of fragments
|
|
11
|
+
*
|
|
12
|
+
* i.e transform:
|
|
13
|
+
* [
|
|
14
|
+
* `query Foo($id: ID!) { foo, bar(id: $id), ...FooQuery }
|
|
15
|
+
* fragment FooQuery on Query { baz }`,
|
|
16
|
+
*
|
|
17
|
+
* `query Bar($id: ID!) { foo: baz, bar(id: $id), ... on Query { baz } }`
|
|
18
|
+
* ]
|
|
19
|
+
* to:
|
|
20
|
+
* query (
|
|
21
|
+
* $graphqlTools1_id: ID!
|
|
22
|
+
* $graphqlTools2_id: ID!
|
|
23
|
+
* ) {
|
|
24
|
+
* graphqlTools1_foo: foo,
|
|
25
|
+
* graphqlTools1_bar: bar(id: $graphqlTools1_id)
|
|
26
|
+
* ... on Query {
|
|
27
|
+
* graphqlTools1__baz: baz
|
|
28
|
+
* }
|
|
29
|
+
* graphqlTools1__foo: baz
|
|
30
|
+
* graphqlTools1__bar: bar(id: $graphqlTools1__id)
|
|
31
|
+
* ... on Query {
|
|
32
|
+
* graphqlTools1__baz: baz
|
|
33
|
+
* }
|
|
34
|
+
* }
|
|
35
|
+
*/
|
|
36
|
+
export declare function mergeRequests(requests: Array<ExecutionRequest>, extensionsReducer: (mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>): ExecutionRequest;
|
package/typings/splitResult.d.ts
CHANGED