@graphql-tools/utils 10.0.1 → 10.0.2-alpha-20230703110056-2a8912fa
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 +1 -0
- package/cjs/mergeIncrementalResult.js +35 -0
- package/esm/index.js +1 -0
- package/esm/mergeIncrementalResult.js +31 -0
- package/package.json +2 -1
- package/typings/index.d.cts +1 -0
- package/typings/index.d.ts +1 -0
- package/typings/mergeIncrementalResult.d.cts +5 -0
- package/typings/mergeIncrementalResult.d.ts +5 -0
package/cjs/index.js
CHANGED
|
@@ -55,3 +55,4 @@ tslib_1.__exportStar(require("./extractExtensionsFromSchema.js"), exports);
|
|
|
55
55
|
tslib_1.__exportStar(require("./Path.js"), exports);
|
|
56
56
|
tslib_1.__exportStar(require("./jsutils.js"), exports);
|
|
57
57
|
tslib_1.__exportStar(require("./directives.js"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./mergeIncrementalResult.js"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeIncrementalResult = void 0;
|
|
4
|
+
const merge_1 = require("dset/merge");
|
|
5
|
+
function mergeIncrementalResult({ incrementalResult, executionResult, }) {
|
|
6
|
+
if (incrementalResult.path) {
|
|
7
|
+
const path = ['data', ...incrementalResult.path];
|
|
8
|
+
executionResult.data = executionResult.data || {};
|
|
9
|
+
if (incrementalResult.items) {
|
|
10
|
+
for (const item of incrementalResult.items) {
|
|
11
|
+
(0, merge_1.dset)(executionResult, path, item);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
if (incrementalResult.data) {
|
|
15
|
+
(0, merge_1.dset)(executionResult, ['data', ...incrementalResult.path], incrementalResult.data);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
else if (incrementalResult.data) {
|
|
19
|
+
executionResult.data = executionResult.data || {};
|
|
20
|
+
Object.assign(executionResult.data, incrementalResult.data);
|
|
21
|
+
}
|
|
22
|
+
if (incrementalResult.errors) {
|
|
23
|
+
executionResult.errors = executionResult.errors || [];
|
|
24
|
+
executionResult.errors.push(...executionResult.errors);
|
|
25
|
+
}
|
|
26
|
+
if (incrementalResult.incremental) {
|
|
27
|
+
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
28
|
+
mergeIncrementalResult({
|
|
29
|
+
incrementalResult: incrementalSubResult,
|
|
30
|
+
executionResult,
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.mergeIncrementalResult = mergeIncrementalResult;
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { dset } from 'dset/merge';
|
|
2
|
+
export function mergeIncrementalResult({ incrementalResult, executionResult, }) {
|
|
3
|
+
if (incrementalResult.path) {
|
|
4
|
+
const path = ['data', ...incrementalResult.path];
|
|
5
|
+
executionResult.data = executionResult.data || {};
|
|
6
|
+
if (incrementalResult.items) {
|
|
7
|
+
for (const item of incrementalResult.items) {
|
|
8
|
+
dset(executionResult, path, item);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (incrementalResult.data) {
|
|
12
|
+
dset(executionResult, ['data', ...incrementalResult.path], incrementalResult.data);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
else if (incrementalResult.data) {
|
|
16
|
+
executionResult.data = executionResult.data || {};
|
|
17
|
+
Object.assign(executionResult.data, incrementalResult.data);
|
|
18
|
+
}
|
|
19
|
+
if (incrementalResult.errors) {
|
|
20
|
+
executionResult.errors = executionResult.errors || [];
|
|
21
|
+
executionResult.errors.push(...executionResult.errors);
|
|
22
|
+
}
|
|
23
|
+
if (incrementalResult.incremental) {
|
|
24
|
+
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
25
|
+
mergeIncrementalResult({
|
|
26
|
+
incrementalResult: incrementalSubResult,
|
|
27
|
+
executionResult,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/utils",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.2-alpha-20230703110056-2a8912fa",
|
|
4
4
|
"description": "Common package containing utils and types for GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@graphql-typed-document-node/core": "^3.1.1",
|
|
11
|
+
"dset": "^3.1.2",
|
|
11
12
|
"tslib": "^2.4.0"
|
|
12
13
|
},
|
|
13
14
|
"repository": {
|
package/typings/index.d.cts
CHANGED
package/typings/index.d.ts
CHANGED