@graphql-tools/executor
Advanced tools
Comparing version 1.2.8 to 1.3.0-rc-20240723153759-69d33f9c6ca6f55b0be47636e2bd24aafec03c04
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isIncrementalResult = exports.getFieldDef = exports.flattenIncrementalResults = exports.subscribe = exports.defaultFieldResolver = exports.defaultTypeResolver = exports.buildResolveInfo = exports.buildExecutionContext = exports.getFragmentsFromDocument = exports.assertValidExecutionArguments = exports.executeSync = exports.execute = void 0; | ||
exports.isIncrementalResult = exports.getFieldDef = exports.flattenIncrementalResults = exports.subscribe = exports.defaultFieldResolver = exports.defaultTypeResolver = exports.CRITICAL_ERROR = exports.buildResolveInfo = exports.buildExecutionContext = exports.getFragmentsFromDocument = exports.assertValidExecutionArguments = exports.executeSync = exports.execute = void 0; | ||
const graphql_1 = require("graphql"); | ||
@@ -86,3 +86,8 @@ const value_or_promise_1 = require("value-or-promise"); | ||
} | ||
exeContext.errors.push(error); | ||
if (error.errors) { | ||
exeContext.errors.push(...error.errors); | ||
} | ||
else { | ||
exeContext.errors.push(error); | ||
} | ||
return buildResponse(null, exeContext.errors); | ||
@@ -332,2 +337,11 @@ }) | ||
return completed.then(undefined, rawError => { | ||
if (rawError instanceof AggregateError) { | ||
return new AggregateError(rawError.errors.map(rawErrorItem => { | ||
rawErrorItem = (0, coerceError_js_1.coerceError)(rawErrorItem); | ||
const error = (0, graphql_1.locatedError)(rawErrorItem, fieldNodes, (0, utils_1.pathToArray)(path)); | ||
const handledError = handleFieldError(error, returnType, errors); | ||
filterSubsequentPayloads(exeContext, path, asyncPayloadRecord); | ||
return handledError; | ||
})); | ||
} | ||
rawError = (0, coerceError_js_1.coerceError)(rawError); | ||
@@ -343,2 +357,9 @@ const error = (0, graphql_1.locatedError)(rawError, fieldNodes, (0, utils_1.pathToArray)(path)); | ||
catch (rawError) { | ||
if (rawError instanceof AggregateError) { | ||
return new AggregateError(rawError.errors.map(rawErrorItem => { | ||
const coercedError = (0, coerceError_js_1.coerceError)(rawErrorItem); | ||
const error = (0, graphql_1.locatedError)(coercedError, fieldNodes, (0, utils_1.pathToArray)(path)); | ||
return handleFieldError(error, returnType, errors); | ||
})); | ||
} | ||
const coercedError = (0, coerceError_js_1.coerceError)(rawError); | ||
@@ -372,2 +393,3 @@ const error = (0, graphql_1.locatedError)(coercedError, fieldNodes, (0, utils_1.pathToArray)(path)); | ||
exports.buildResolveInfo = buildResolveInfo; | ||
exports.CRITICAL_ERROR = 'CRITICAL_ERROR'; | ||
function handleFieldError(error, returnType, errors) { | ||
@@ -379,2 +401,5 @@ // If the field type is non-nullable, then it is resolved without any | ||
} | ||
if (error.extensions?.[exports.CRITICAL_ERROR]) { | ||
throw error; | ||
} | ||
// Otherwise, error protection is applied, logging the error and resolving | ||
@@ -862,9 +887,14 @@ // a null value for this field if one is encountered. | ||
return (0, flattenAsyncIterable_js_1.flattenAsyncIterable)((0, utils_1.mapAsyncIterator)(resultOrStream[Symbol.asyncIterator](), async (payload) => ensureAsyncIterable(await executeImpl(buildPerEventExecutionContext(exeContext, payload))), (error) => { | ||
const wrappedError = (0, utils_1.createGraphQLError)(error.message, { | ||
originalError: error, | ||
nodes: [exeContext.operation], | ||
}); | ||
throw wrappedError; | ||
if (error instanceof AggregateError) { | ||
throw new AggregateError(error.errors.map(e => wrapError(e, exeContext.operation)), error.message); | ||
} | ||
throw wrapError(error, exeContext.operation); | ||
})); | ||
} | ||
function wrapError(error, operation) { | ||
return (0, utils_1.createGraphQLError)(error.message, { | ||
originalError: error, | ||
nodes: [operation], | ||
}); | ||
} | ||
function createSourceEventStreamImpl(exeContext) { | ||
@@ -871,0 +901,0 @@ try { |
@@ -82,3 +82,8 @@ import { assertValidSchema, getDirectiveValues, GraphQLError, isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, Kind, locatedError, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, versionInfo, } from 'graphql'; | ||
} | ||
exeContext.errors.push(error); | ||
if (error.errors) { | ||
exeContext.errors.push(...error.errors); | ||
} | ||
else { | ||
exeContext.errors.push(error); | ||
} | ||
return buildResponse(null, exeContext.errors); | ||
@@ -325,2 +330,11 @@ }) | ||
return completed.then(undefined, rawError => { | ||
if (rawError instanceof AggregateError) { | ||
return new AggregateError(rawError.errors.map(rawErrorItem => { | ||
rawErrorItem = coerceError(rawErrorItem); | ||
const error = locatedError(rawErrorItem, fieldNodes, pathToArray(path)); | ||
const handledError = handleFieldError(error, returnType, errors); | ||
filterSubsequentPayloads(exeContext, path, asyncPayloadRecord); | ||
return handledError; | ||
})); | ||
} | ||
rawError = coerceError(rawError); | ||
@@ -336,2 +350,9 @@ const error = locatedError(rawError, fieldNodes, pathToArray(path)); | ||
catch (rawError) { | ||
if (rawError instanceof AggregateError) { | ||
return new AggregateError(rawError.errors.map(rawErrorItem => { | ||
const coercedError = coerceError(rawErrorItem); | ||
const error = locatedError(coercedError, fieldNodes, pathToArray(path)); | ||
return handleFieldError(error, returnType, errors); | ||
})); | ||
} | ||
const coercedError = coerceError(rawError); | ||
@@ -364,2 +385,3 @@ const error = locatedError(coercedError, fieldNodes, pathToArray(path)); | ||
} | ||
export const CRITICAL_ERROR = 'CRITICAL_ERROR'; | ||
function handleFieldError(error, returnType, errors) { | ||
@@ -371,2 +393,5 @@ // If the field type is non-nullable, then it is resolved without any | ||
} | ||
if (error.extensions?.[CRITICAL_ERROR]) { | ||
throw error; | ||
} | ||
// Otherwise, error protection is applied, logging the error and resolving | ||
@@ -850,9 +875,14 @@ // a null value for this field if one is encountered. | ||
return flattenAsyncIterable(mapAsyncIterator(resultOrStream[Symbol.asyncIterator](), async (payload) => ensureAsyncIterable(await executeImpl(buildPerEventExecutionContext(exeContext, payload))), (error) => { | ||
const wrappedError = createGraphQLError(error.message, { | ||
originalError: error, | ||
nodes: [exeContext.operation], | ||
}); | ||
throw wrappedError; | ||
if (error instanceof AggregateError) { | ||
throw new AggregateError(error.errors.map(e => wrapError(e, exeContext.operation)), error.message); | ||
} | ||
throw wrapError(error, exeContext.operation); | ||
})); | ||
} | ||
function wrapError(error, operation) { | ||
return createGraphQLError(error.message, { | ||
originalError: error, | ||
nodes: [operation], | ||
}); | ||
} | ||
function createSourceEventStreamImpl(exeContext) { | ||
@@ -859,0 +889,0 @@ try { |
{ | ||
"name": "@graphql-tools/executor", | ||
"version": "1.2.8", | ||
"version": "1.3.0-rc-20240723153759-69d33f9c6ca6f55b0be47636e2bd24aafec03c04", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
@@ -155,2 +155,3 @@ import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLFormattedError, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql'; | ||
export declare function buildResolveInfo(exeContext: ExecutionContext, fieldDef: GraphQLField<unknown, unknown>, fieldNodes: Array<FieldNode>, parentType: GraphQLObjectType, path: Path): GraphQLResolveInfo; | ||
export declare const CRITICAL_ERROR: "CRITICAL_ERROR"; | ||
/** | ||
@@ -157,0 +158,0 @@ * If a resolveType function is not given, then a default resolve behavior is |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169169
3519
2