@graphql-tools/utils 10.11.0-alpha-20251110221147-3e773b194d7b3e752eb121d0bec4e49919d9f1f9 → 10.11.0-alpha-20251113153404-aa3328c5a0bf7ec4395c788dde43fda08409300c
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/errors.js +7 -8
- package/cjs/mergeIncrementalResult.js +4 -25
- package/esm/errors.js +8 -9
- package/esm/mergeIncrementalResult.js +4 -25
- package/package.json +2 -1
- package/typings/errors.d.cts +1 -1
- package/typings/errors.d.ts +1 -1
package/cjs/errors.js
CHANGED
|
@@ -17,6 +17,7 @@ const possibleGraphQLErrorProperties = [
|
|
|
17
17
|
'name',
|
|
18
18
|
'stack',
|
|
19
19
|
'extensions',
|
|
20
|
+
'coordinate',
|
|
20
21
|
];
|
|
21
22
|
function isGraphQLErrorLike(error) {
|
|
22
23
|
return (error != null &&
|
|
@@ -29,14 +30,12 @@ function createGraphQLError(message, options) {
|
|
|
29
30
|
isGraphQLErrorLike(options.originalError)) {
|
|
30
31
|
options.originalError = createGraphQLError(options.originalError.message, options.originalError);
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (options?.coordinate != null && !error.coordinate) {
|
|
33
|
+
// To avoid type error on graphql <16, we have to use an any type here
|
|
34
|
+
const Constructor = graphql_1.GraphQLError;
|
|
35
|
+
const error = graphql_1.versionInfo.major >= 16
|
|
36
|
+
? new Constructor(message, options)
|
|
37
|
+
: new Constructor(message, options?.nodes, options?.source, options?.positions, options?.path, options?.originalError, options?.extensions);
|
|
38
|
+
if (options?.coordinate) {
|
|
40
39
|
Object.defineProperty(error, 'coordinate', {
|
|
41
40
|
value: options.coordinate,
|
|
42
41
|
enumerable: true,
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeIncrementalResult = mergeIncrementalResult;
|
|
4
|
-
const
|
|
4
|
+
const merge_1 = require("dset/merge");
|
|
5
5
|
function mergeIncrementalResult({ incrementalResult, executionResult, }) {
|
|
6
6
|
const path = ['data', ...(incrementalResult.path ?? [])];
|
|
7
7
|
if (incrementalResult.items) {
|
|
8
8
|
for (const item of incrementalResult.items) {
|
|
9
|
-
|
|
9
|
+
(0, merge_1.dset)(executionResult, path, item);
|
|
10
10
|
// Increment the last path segment (the array index) to merge the next item at the next index
|
|
11
11
|
path[path.length - 1]++;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
if (incrementalResult.data) {
|
|
15
|
-
|
|
15
|
+
(0, merge_1.dset)(executionResult, path, incrementalResult.data);
|
|
16
16
|
}
|
|
17
17
|
if (incrementalResult.errors) {
|
|
18
18
|
executionResult.errors = executionResult.errors || [];
|
|
19
19
|
executionResult.errors.push(...incrementalResult.errors);
|
|
20
20
|
}
|
|
21
21
|
if (incrementalResult.extensions) {
|
|
22
|
-
|
|
22
|
+
(0, merge_1.dset)(executionResult, 'extensions', incrementalResult.extensions);
|
|
23
23
|
}
|
|
24
24
|
if (incrementalResult.incremental) {
|
|
25
25
|
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
@@ -30,24 +30,3 @@ function mergeIncrementalResult({ incrementalResult, executionResult, }) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
function setObjectKeyPath(obj, keyPath, value) {
|
|
34
|
-
let current = obj;
|
|
35
|
-
let i;
|
|
36
|
-
for (i = 0; i < keyPath.length - 1; i++) {
|
|
37
|
-
const key = keyPath[i];
|
|
38
|
-
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (current[key] == null) {
|
|
42
|
-
// Determine if the next key is a number to create an array, otherwise create an object
|
|
43
|
-
current[key] = typeof keyPath[i + 1] === 'number' ? [] : {};
|
|
44
|
-
}
|
|
45
|
-
current = current[key];
|
|
46
|
-
}
|
|
47
|
-
const finalKey = keyPath[i];
|
|
48
|
-
if (finalKey === '__proto__' || finalKey === 'constructor' || finalKey === 'prototype') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const existingValue = current[finalKey];
|
|
52
|
-
current[finalKey] = existingValue != null ? (0, mergeDeep_js_1.mergeDeep)([existingValue, value]) : value;
|
|
53
|
-
}
|
package/esm/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { locatedError as _locatedError, GraphQLError, versionInfo
|
|
1
|
+
import { locatedError as _locatedError, GraphQLError, versionInfo } from 'graphql';
|
|
2
2
|
const possibleGraphQLErrorProperties = [
|
|
3
3
|
'message',
|
|
4
4
|
'locations',
|
|
@@ -10,6 +10,7 @@ const possibleGraphQLErrorProperties = [
|
|
|
10
10
|
'name',
|
|
11
11
|
'stack',
|
|
12
12
|
'extensions',
|
|
13
|
+
'coordinate',
|
|
13
14
|
];
|
|
14
15
|
export function isGraphQLErrorLike(error) {
|
|
15
16
|
return (error != null &&
|
|
@@ -22,14 +23,12 @@ export function createGraphQLError(message, options) {
|
|
|
22
23
|
isGraphQLErrorLike(options.originalError)) {
|
|
23
24
|
options.originalError = createGraphQLError(options.originalError.message, options.originalError);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
if (options?.coordinate != null && !error.coordinate) {
|
|
26
|
+
// To avoid type error on graphql <16, we have to use an any type here
|
|
27
|
+
const Constructor = GraphQLError;
|
|
28
|
+
const error = versionInfo.major >= 16
|
|
29
|
+
? new Constructor(message, options)
|
|
30
|
+
: new Constructor(message, options?.nodes, options?.source, options?.positions, options?.path, options?.originalError, options?.extensions);
|
|
31
|
+
if (options?.coordinate) {
|
|
33
32
|
Object.defineProperty(error, 'coordinate', {
|
|
34
33
|
value: options.coordinate,
|
|
35
34
|
enumerable: true,
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { dset } from 'dset/merge';
|
|
2
2
|
export function mergeIncrementalResult({ incrementalResult, executionResult, }) {
|
|
3
3
|
const path = ['data', ...(incrementalResult.path ?? [])];
|
|
4
4
|
if (incrementalResult.items) {
|
|
5
5
|
for (const item of incrementalResult.items) {
|
|
6
|
-
|
|
6
|
+
dset(executionResult, path, item);
|
|
7
7
|
// Increment the last path segment (the array index) to merge the next item at the next index
|
|
8
8
|
path[path.length - 1]++;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
if (incrementalResult.data) {
|
|
12
|
-
|
|
12
|
+
dset(executionResult, path, incrementalResult.data);
|
|
13
13
|
}
|
|
14
14
|
if (incrementalResult.errors) {
|
|
15
15
|
executionResult.errors = executionResult.errors || [];
|
|
16
16
|
executionResult.errors.push(...incrementalResult.errors);
|
|
17
17
|
}
|
|
18
18
|
if (incrementalResult.extensions) {
|
|
19
|
-
|
|
19
|
+
dset(executionResult, 'extensions', incrementalResult.extensions);
|
|
20
20
|
}
|
|
21
21
|
if (incrementalResult.incremental) {
|
|
22
22
|
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
@@ -27,24 +27,3 @@ export function mergeIncrementalResult({ incrementalResult, executionResult, })
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
function setObjectKeyPath(obj, keyPath, value) {
|
|
31
|
-
let current = obj;
|
|
32
|
-
let i;
|
|
33
|
-
for (i = 0; i < keyPath.length - 1; i++) {
|
|
34
|
-
const key = keyPath[i];
|
|
35
|
-
if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (current[key] == null) {
|
|
39
|
-
// Determine if the next key is a number to create an array, otherwise create an object
|
|
40
|
-
current[key] = typeof keyPath[i + 1] === 'number' ? [] : {};
|
|
41
|
-
}
|
|
42
|
-
current = current[key];
|
|
43
|
-
}
|
|
44
|
-
const finalKey = keyPath[i];
|
|
45
|
-
if (finalKey === '__proto__' || finalKey === 'constructor' || finalKey === 'prototype') {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const existingValue = current[finalKey];
|
|
49
|
-
current[finalKey] = existingValue != null ? mergeDeep([existingValue, value]) : value;
|
|
50
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/utils",
|
|
3
|
-
"version": "10.11.0-alpha-
|
|
3
|
+
"version": "10.11.0-alpha-20251113153404-aa3328c5a0bf7ec4395c788dde43fda08409300c",
|
|
4
4
|
"description": "Common package containing utils and types for GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"@graphql-typed-document-node/core": "^3.1.1",
|
|
11
11
|
"@whatwg-node/promise-helpers": "^1.0.0",
|
|
12
12
|
"cross-inspect": "1.0.1",
|
|
13
|
+
"dset": "^3.1.4",
|
|
13
14
|
"tslib": "^2.4.0"
|
|
14
15
|
},
|
|
15
16
|
"repository": {
|
package/typings/errors.d.cts
CHANGED
|
@@ -11,7 +11,6 @@ interface GraphQLErrorOptions {
|
|
|
11
11
|
extensions?: any;
|
|
12
12
|
coordinate?: string;
|
|
13
13
|
}
|
|
14
|
-
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
15
14
|
declare module 'graphql' {
|
|
16
15
|
interface GraphQLError {
|
|
17
16
|
/**
|
|
@@ -20,6 +19,7 @@ declare module 'graphql' {
|
|
|
20
19
|
readonly coordinate?: string;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
22
|
+
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
23
23
|
export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
|
|
24
24
|
type SchemaCoordinateInfo = {
|
|
25
25
|
fieldName: string;
|
package/typings/errors.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ interface GraphQLErrorOptions {
|
|
|
11
11
|
extensions?: any;
|
|
12
12
|
coordinate?: string;
|
|
13
13
|
}
|
|
14
|
-
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
15
14
|
declare module 'graphql' {
|
|
16
15
|
interface GraphQLError {
|
|
17
16
|
/**
|
|
@@ -20,6 +19,7 @@ declare module 'graphql' {
|
|
|
20
19
|
readonly coordinate?: string;
|
|
21
20
|
}
|
|
22
21
|
}
|
|
22
|
+
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
23
23
|
export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
|
|
24
24
|
type SchemaCoordinateInfo = {
|
|
25
25
|
fieldName: string;
|