@graphql-tools/utils 11.0.0-alpha-20250924154028-1622fafe0f672d0c41ae751327b4f849bfff0d9f → 11.0.0-alpha-20251224084859-76041a3e34f4ada36bb2f3f1ab3bcd0956d5873f
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/build-operation-for-field.js +21 -0
- package/cjs/errors.js +30 -4
- package/cjs/mergeIncrementalResult.js +25 -4
- package/cjs/print-schema-with-directives.js +1 -1
- package/esm/build-operation-for-field.js +22 -1
- package/esm/errors.js +29 -6
- package/esm/mergeIncrementalResult.js +25 -4
- package/esm/print-schema-with-directives.js +1 -1
- package/package.json +1 -2
- package/typings/Interfaces.d.cts +7 -0
- package/typings/Interfaces.d.ts +7 -0
- package/typings/errors.d.cts +19 -1
- package/typings/errors.d.ts +19 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildOperationNodeForField = buildOperationNodeForField;
|
|
4
4
|
const graphql_1 = require("graphql");
|
|
5
|
+
const astFromValueUntyped_js_1 = require("./astFromValueUntyped.js");
|
|
5
6
|
const rootTypes_js_1 = require("./rootTypes.js");
|
|
6
7
|
let operationVariables = [];
|
|
7
8
|
let fieldTypeMap = new Map();
|
|
@@ -241,6 +242,25 @@ function resolveVariable(arg, name) {
|
|
|
241
242
|
},
|
|
242
243
|
};
|
|
243
244
|
}
|
|
245
|
+
let defaultValue;
|
|
246
|
+
try {
|
|
247
|
+
const returnVal = (0, graphql_1.astFromValue)(arg.defaultValue, arg.type);
|
|
248
|
+
if (returnVal == null) {
|
|
249
|
+
defaultValue = undefined;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
defaultValue = returnVal;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
catch (e) {
|
|
256
|
+
const returnVal = (0, astFromValueUntyped_js_1.astFromValueUntyped)(arg.defaultValue);
|
|
257
|
+
if (returnVal == null) {
|
|
258
|
+
defaultValue = undefined;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
defaultValue = returnVal;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
244
264
|
return {
|
|
245
265
|
kind: graphql_1.Kind.VARIABLE_DEFINITION,
|
|
246
266
|
variable: {
|
|
@@ -251,6 +271,7 @@ function resolveVariable(arg, name) {
|
|
|
251
271
|
},
|
|
252
272
|
},
|
|
253
273
|
type: resolveVariableType(arg.type),
|
|
274
|
+
defaultValue,
|
|
254
275
|
};
|
|
255
276
|
}
|
|
256
277
|
function getArgumentName(name, path) {
|
package/cjs/errors.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isGraphQLErrorLike = isGraphQLErrorLike;
|
|
3
4
|
exports.createGraphQLError = createGraphQLError;
|
|
5
|
+
exports.getSchemaCoordinate = getSchemaCoordinate;
|
|
6
|
+
exports.locatedError = locatedError;
|
|
4
7
|
exports.relocatedError = relocatedError;
|
|
5
8
|
const graphql_1 = require("graphql");
|
|
6
9
|
const possibleGraphQLErrorProperties = [
|
|
@@ -14,6 +17,7 @@ const possibleGraphQLErrorProperties = [
|
|
|
14
17
|
'name',
|
|
15
18
|
'stack',
|
|
16
19
|
'extensions',
|
|
20
|
+
'coordinate',
|
|
17
21
|
];
|
|
18
22
|
function isGraphQLErrorLike(error) {
|
|
19
23
|
return (error != null &&
|
|
@@ -26,12 +30,33 @@ function createGraphQLError(message, options) {
|
|
|
26
30
|
isGraphQLErrorLike(options.originalError)) {
|
|
27
31
|
options.originalError = createGraphQLError(options.originalError.message, options.originalError);
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
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 && error.coordinate == null) {
|
|
39
|
+
Object.defineProperties(error, {
|
|
40
|
+
coordinate: { value: options.coordinate, enumerable: true, configurable: true },
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
|
-
return
|
|
43
|
+
return error;
|
|
33
44
|
}
|
|
34
|
-
function
|
|
45
|
+
function getSchemaCoordinate(error) {
|
|
46
|
+
return error.coordinate;
|
|
47
|
+
}
|
|
48
|
+
function locatedError(rawError, nodes, path, info) {
|
|
49
|
+
const error = (0, graphql_1.locatedError)(rawError, nodes, path);
|
|
50
|
+
// `graphql` locatedError is only changing path and nodes if it is not already defined
|
|
51
|
+
if (!error.coordinate && info && error.coordinate == null) {
|
|
52
|
+
const coordinate = `${info.parentType.name}.${info.fieldName}`;
|
|
53
|
+
Object.defineProperties(error, {
|
|
54
|
+
coordinate: { value: coordinate, enumerable: true, configurable: true },
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return error;
|
|
58
|
+
}
|
|
59
|
+
function relocatedError(originalError, path, info) {
|
|
35
60
|
return createGraphQLError(originalError.message, {
|
|
36
61
|
nodes: originalError.nodes,
|
|
37
62
|
source: originalError.source,
|
|
@@ -39,5 +64,6 @@ function relocatedError(originalError, path) {
|
|
|
39
64
|
path: path == null ? originalError.path : path,
|
|
40
65
|
originalError,
|
|
41
66
|
extensions: originalError.extensions,
|
|
67
|
+
coordinate: info ? `${info.parentType.name}.${info.fieldName}` : undefined,
|
|
42
68
|
});
|
|
43
69
|
}
|
|
@@ -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 mergeDeep_js_1 = require("./mergeDeep.js");
|
|
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
|
+
setObjectKeyPath(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
|
+
setObjectKeyPath(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
|
+
setObjectKeyPath(executionResult, ['extensions'], incrementalResult.extensions);
|
|
23
23
|
}
|
|
24
24
|
if (incrementalResult.incremental) {
|
|
25
25
|
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
@@ -30,3 +30,24 @@ 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
|
+
}
|
|
@@ -123,7 +123,7 @@ function astFromSchema(schema, pathToDirectivesInExtensions) {
|
|
|
123
123
|
return null;
|
|
124
124
|
}
|
|
125
125
|
const schemaNode = {
|
|
126
|
-
kind: operationTypes
|
|
126
|
+
kind: operationTypes.length ? graphql_1.Kind.SCHEMA_DEFINITION : graphql_1.Kind.SCHEMA_EXTENSION,
|
|
127
127
|
operationTypes,
|
|
128
128
|
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
|
|
129
129
|
directives: directives,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getNamedType, isEnumType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, Kind, } from 'graphql';
|
|
1
|
+
import { astFromValue, getNamedType, isEnumType, isInterfaceType, isListType, isNonNullType, isObjectType, isScalarType, isUnionType, Kind, } from 'graphql';
|
|
2
|
+
import { astFromValueUntyped } from './astFromValueUntyped.js';
|
|
2
3
|
import { getDefinedRootType, getRootTypeNames } from './rootTypes.js';
|
|
3
4
|
let operationVariables = [];
|
|
4
5
|
let fieldTypeMap = new Map();
|
|
@@ -238,6 +239,25 @@ function resolveVariable(arg, name) {
|
|
|
238
239
|
},
|
|
239
240
|
};
|
|
240
241
|
}
|
|
242
|
+
let defaultValue;
|
|
243
|
+
try {
|
|
244
|
+
const returnVal = astFromValue(arg.defaultValue, arg.type);
|
|
245
|
+
if (returnVal == null) {
|
|
246
|
+
defaultValue = undefined;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
defaultValue = returnVal;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
const returnVal = astFromValueUntyped(arg.defaultValue);
|
|
254
|
+
if (returnVal == null) {
|
|
255
|
+
defaultValue = undefined;
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
defaultValue = returnVal;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
241
261
|
return {
|
|
242
262
|
kind: Kind.VARIABLE_DEFINITION,
|
|
243
263
|
variable: {
|
|
@@ -248,6 +268,7 @@ function resolveVariable(arg, name) {
|
|
|
248
268
|
},
|
|
249
269
|
},
|
|
250
270
|
type: resolveVariableType(arg.type),
|
|
271
|
+
defaultValue,
|
|
251
272
|
};
|
|
252
273
|
}
|
|
253
274
|
function getArgumentName(name, path) {
|
package/esm/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLError, versionInfo } from 'graphql';
|
|
1
|
+
import { locatedError as _locatedError, GraphQLError, versionInfo } from 'graphql';
|
|
2
2
|
const possibleGraphQLErrorProperties = [
|
|
3
3
|
'message',
|
|
4
4
|
'locations',
|
|
@@ -10,8 +10,9 @@ const possibleGraphQLErrorProperties = [
|
|
|
10
10
|
'name',
|
|
11
11
|
'stack',
|
|
12
12
|
'extensions',
|
|
13
|
+
'coordinate',
|
|
13
14
|
];
|
|
14
|
-
function isGraphQLErrorLike(error) {
|
|
15
|
+
export function isGraphQLErrorLike(error) {
|
|
15
16
|
return (error != null &&
|
|
16
17
|
typeof error === 'object' &&
|
|
17
18
|
Object.keys(error).every(key => possibleGraphQLErrorProperties.includes(key)));
|
|
@@ -22,12 +23,33 @@ export function createGraphQLError(message, options) {
|
|
|
22
23
|
isGraphQLErrorLike(options.originalError)) {
|
|
23
24
|
options.originalError = createGraphQLError(options.originalError.message, options.originalError);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
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 && error.coordinate == null) {
|
|
32
|
+
Object.defineProperties(error, {
|
|
33
|
+
coordinate: { value: options.coordinate, enumerable: true, configurable: true },
|
|
34
|
+
});
|
|
27
35
|
}
|
|
28
|
-
return
|
|
36
|
+
return error;
|
|
29
37
|
}
|
|
30
|
-
export function
|
|
38
|
+
export function getSchemaCoordinate(error) {
|
|
39
|
+
return error.coordinate;
|
|
40
|
+
}
|
|
41
|
+
export function locatedError(rawError, nodes, path, info) {
|
|
42
|
+
const error = _locatedError(rawError, nodes, path);
|
|
43
|
+
// `graphql` locatedError is only changing path and nodes if it is not already defined
|
|
44
|
+
if (!error.coordinate && info && error.coordinate == null) {
|
|
45
|
+
const coordinate = `${info.parentType.name}.${info.fieldName}`;
|
|
46
|
+
Object.defineProperties(error, {
|
|
47
|
+
coordinate: { value: coordinate, enumerable: true, configurable: true },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return error;
|
|
51
|
+
}
|
|
52
|
+
export function relocatedError(originalError, path, info) {
|
|
31
53
|
return createGraphQLError(originalError.message, {
|
|
32
54
|
nodes: originalError.nodes,
|
|
33
55
|
source: originalError.source,
|
|
@@ -35,5 +57,6 @@ export function relocatedError(originalError, path) {
|
|
|
35
57
|
path: path == null ? originalError.path : path,
|
|
36
58
|
originalError,
|
|
37
59
|
extensions: originalError.extensions,
|
|
60
|
+
coordinate: info ? `${info.parentType.name}.${info.fieldName}` : undefined,
|
|
38
61
|
});
|
|
39
62
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeDeep } from './mergeDeep.js';
|
|
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
|
+
setObjectKeyPath(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
|
+
setObjectKeyPath(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
|
+
setObjectKeyPath(executionResult, ['extensions'], incrementalResult.extensions);
|
|
20
20
|
}
|
|
21
21
|
if (incrementalResult.incremental) {
|
|
22
22
|
incrementalResult.incremental.forEach(incrementalSubResult => {
|
|
@@ -27,3 +27,24 @@ 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
|
+
}
|
|
@@ -103,7 +103,7 @@ export function astFromSchema(schema, pathToDirectivesInExtensions) {
|
|
|
103
103
|
return null;
|
|
104
104
|
}
|
|
105
105
|
const schemaNode = {
|
|
106
|
-
kind: operationTypes
|
|
106
|
+
kind: operationTypes.length ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
|
|
107
107
|
operationTypes,
|
|
108
108
|
// ConstXNode has been introduced in v16 but it is not compatible with XNode so we do `as any` for backwards compatibility
|
|
109
109
|
directives: directives,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/utils",
|
|
3
|
-
"version": "11.0.0-alpha-
|
|
3
|
+
"version": "11.0.0-alpha-20251224084859-76041a3e34f4ada36bb2f3f1ab3bcd0956d5873f",
|
|
4
4
|
"description": "Common package containing utils and types for GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
@@ -10,7 +10,6 @@
|
|
|
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",
|
|
14
13
|
"tslib": "^2.4.0"
|
|
15
14
|
},
|
|
16
15
|
"repository": {
|
package/typings/Interfaces.d.cts
CHANGED
|
@@ -32,6 +32,13 @@ export interface ExecutionRequest<TVariables extends Record<string, any> = any,
|
|
|
32
32
|
subgraphName?: string;
|
|
33
33
|
info?: GraphQLResolveInfo;
|
|
34
34
|
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* Enable/Disable the addition of field schema coordinate in GraphQL Errors extension
|
|
37
|
+
*
|
|
38
|
+
* Note: Schema Coordinate are exposed using Symbol.for('schemaCoordinate') so that it's not
|
|
39
|
+
* serialized. Exposing schema coordinate can ease the discovery of private schemas.
|
|
40
|
+
*/
|
|
41
|
+
schemaCoordinateInErrors?: boolean;
|
|
35
42
|
}
|
|
36
43
|
export interface GraphQLParseOptions {
|
|
37
44
|
noLocation?: boolean;
|
package/typings/Interfaces.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ export interface ExecutionRequest<TVariables extends Record<string, any> = any,
|
|
|
32
32
|
subgraphName?: string;
|
|
33
33
|
info?: GraphQLResolveInfo;
|
|
34
34
|
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* Enable/Disable the addition of field schema coordinate in GraphQL Errors extension
|
|
37
|
+
*
|
|
38
|
+
* Note: Schema Coordinate are exposed using Symbol.for('schemaCoordinate') so that it's not
|
|
39
|
+
* serialized. Exposing schema coordinate can ease the discovery of private schemas.
|
|
40
|
+
*/
|
|
41
|
+
schemaCoordinateInErrors?: boolean;
|
|
35
42
|
}
|
|
36
43
|
export interface GraphQLParseOptions {
|
|
37
44
|
noLocation?: boolean;
|
package/typings/errors.d.cts
CHANGED
|
@@ -9,7 +9,25 @@ interface GraphQLErrorOptions {
|
|
|
9
9
|
readonly extensions?: unknown;
|
|
10
10
|
}>;
|
|
11
11
|
extensions?: any;
|
|
12
|
+
coordinate?: string;
|
|
12
13
|
}
|
|
14
|
+
declare module 'graphql' {
|
|
15
|
+
interface GraphQLError {
|
|
16
|
+
/**
|
|
17
|
+
* An optional schema coordinate (e.g. "MyType.myField") associated with this error.
|
|
18
|
+
*/
|
|
19
|
+
readonly coordinate?: string;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
13
23
|
export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
|
|
14
|
-
|
|
24
|
+
type SchemaCoordinateInfo = {
|
|
25
|
+
fieldName: string;
|
|
26
|
+
parentType: {
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function getSchemaCoordinate(error: GraphQLError): string | undefined;
|
|
31
|
+
export declare function locatedError(rawError: unknown, nodes: ASTNode | ReadonlyArray<ASTNode> | undefined, path: Maybe<ReadonlyArray<string | number>>, info?: SchemaCoordinateInfo | false | null | undefined): GraphQLError;
|
|
32
|
+
export declare function relocatedError(originalError: GraphQLError, path?: ReadonlyArray<string | number>, info?: SchemaCoordinateInfo | false | null | undefined): GraphQLError;
|
|
15
33
|
export {};
|
package/typings/errors.d.ts
CHANGED
|
@@ -9,7 +9,25 @@ interface GraphQLErrorOptions {
|
|
|
9
9
|
readonly extensions?: unknown;
|
|
10
10
|
}>;
|
|
11
11
|
extensions?: any;
|
|
12
|
+
coordinate?: string;
|
|
12
13
|
}
|
|
14
|
+
declare module 'graphql' {
|
|
15
|
+
interface GraphQLError {
|
|
16
|
+
/**
|
|
17
|
+
* An optional schema coordinate (e.g. "MyType.myField") associated with this error.
|
|
18
|
+
*/
|
|
19
|
+
readonly coordinate?: string;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export declare function isGraphQLErrorLike(error: any): boolean;
|
|
13
23
|
export declare function createGraphQLError(message: string, options?: GraphQLErrorOptions): GraphQLError;
|
|
14
|
-
|
|
24
|
+
type SchemaCoordinateInfo = {
|
|
25
|
+
fieldName: string;
|
|
26
|
+
parentType: {
|
|
27
|
+
name: string;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare function getSchemaCoordinate(error: GraphQLError): string | undefined;
|
|
31
|
+
export declare function locatedError(rawError: unknown, nodes: ASTNode | ReadonlyArray<ASTNode> | undefined, path: Maybe<ReadonlyArray<string | number>>, info?: SchemaCoordinateInfo | false | null | undefined): GraphQLError;
|
|
32
|
+
export declare function relocatedError(originalError: GraphQLError, path?: ReadonlyArray<string | number>, info?: SchemaCoordinateInfo | false | null | undefined): GraphQLError;
|
|
15
33
|
export {};
|