@graphql-tools/executor
Advanced tools
Comparing version 1.2.5-alpha-20240328134228-8452ac4e9c9e6970bfeb2ff7ab914352a0d7a646 to 1.2.5-alpha-20240328143324-239661c7f22ace5ca5539cc5b2e9f2e5fb67b38c
@@ -82,2 +82,5 @@ "use strict"; | ||
}, (error) => { | ||
if (exeContext.signal?.aborted) { | ||
throw exeContext.signal.reason; | ||
} | ||
exeContext.errors.push(error); | ||
@@ -87,20 +90,3 @@ return buildResponse(null, exeContext.errors); | ||
.resolve(); | ||
if (!exeContext.signal || 'initialResult' in result || 'then' in result === false) { | ||
return result; | ||
} | ||
let resolve; | ||
let reject; | ||
const abortP = new Promise((_resolve, _reject) => { | ||
resolve = _resolve; | ||
reject = _reject; | ||
}); | ||
function abortListener() { | ||
reject(exeContext.signal?.reason); | ||
} | ||
exeContext.signal.addEventListener('abort', abortListener); | ||
result.then(() => { | ||
exeContext.signal?.removeEventListener('abort', abortListener); | ||
resolve(); | ||
}); | ||
return Promise.race([abortP, result]); | ||
return result; | ||
} | ||
@@ -255,8 +241,6 @@ /** | ||
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) { | ||
let abortErrorThrown = false; | ||
return (0, utils_1.promiseReduce)(fields, (results, [responseName, fieldNodes]) => { | ||
const fieldPath = (0, utils_1.addPath)(path, responseName, parentType.name); | ||
if (exeContext.signal?.aborted) { | ||
results[responseName] = null; | ||
return results; | ||
throw exeContext.signal.reason; | ||
} | ||
@@ -268,10 +252,2 @@ return new value_or_promise_1.ValueOrPromise(() => executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath)).then(result => { | ||
results[responseName] = result; | ||
if (exeContext.signal?.aborted && !abortErrorThrown) { | ||
exeContext.errors.push((0, utils_1.createGraphQLError)('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: (0, utils_1.pathToArray)(fieldPath), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
abortErrorThrown = true; | ||
} | ||
return results; | ||
@@ -288,8 +264,6 @@ }); | ||
let containsPromise = false; | ||
let abortErrorThrown = false; | ||
try { | ||
for (const [responseName, fieldNodes] of fields) { | ||
if (exeContext.signal?.aborted) { | ||
results[responseName] = null; | ||
continue; | ||
throw exeContext.signal.reason; | ||
} | ||
@@ -304,10 +278,2 @@ const fieldPath = (0, utils_1.addPath)(path, responseName, parentType.name); | ||
} | ||
if (exeContext.signal?.aborted && !abortErrorThrown) { | ||
exeContext.errors.push((0, utils_1.createGraphQLError)('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: (0, utils_1.pathToArray)(fieldPath), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
abortErrorThrown = true; | ||
} | ||
} | ||
@@ -511,7 +477,2 @@ } | ||
iterator.return?.(); | ||
exeContext.errors.push((0, utils_1.createGraphQLError)('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: (0, utils_1.pathToArray)(path), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
}); | ||
@@ -518,0 +479,0 @@ const errors = asyncPayloadRecord?.errors ?? exeContext.errors; |
@@ -15,3 +15,3 @@ "use strict"; | ||
signal?.addEventListener('abort', () => { | ||
resolve(); | ||
reject(signal.reason); | ||
}); | ||
@@ -18,0 +18,0 @@ Promise.all(Object.entries(object).map(async ([key, value]) => { |
@@ -78,2 +78,5 @@ import { assertValidSchema, getDirectiveValues, GraphQLError, isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, Kind, locatedError, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, } from 'graphql'; | ||
}, (error) => { | ||
if (exeContext.signal?.aborted) { | ||
throw exeContext.signal.reason; | ||
} | ||
exeContext.errors.push(error); | ||
@@ -83,20 +86,3 @@ return buildResponse(null, exeContext.errors); | ||
.resolve(); | ||
if (!exeContext.signal || 'initialResult' in result || 'then' in result === false) { | ||
return result; | ||
} | ||
let resolve; | ||
let reject; | ||
const abortP = new Promise((_resolve, _reject) => { | ||
resolve = _resolve; | ||
reject = _reject; | ||
}); | ||
function abortListener() { | ||
reject(exeContext.signal?.reason); | ||
} | ||
exeContext.signal.addEventListener('abort', abortListener); | ||
result.then(() => { | ||
exeContext.signal?.removeEventListener('abort', abortListener); | ||
resolve(); | ||
}); | ||
return Promise.race([abortP, result]); | ||
return result; | ||
} | ||
@@ -248,8 +234,6 @@ /** | ||
function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) { | ||
let abortErrorThrown = false; | ||
return promiseReduce(fields, (results, [responseName, fieldNodes]) => { | ||
const fieldPath = addPath(path, responseName, parentType.name); | ||
if (exeContext.signal?.aborted) { | ||
results[responseName] = null; | ||
return results; | ||
throw exeContext.signal.reason; | ||
} | ||
@@ -261,10 +245,2 @@ return new ValueOrPromise(() => executeField(exeContext, parentType, sourceValue, fieldNodes, fieldPath)).then(result => { | ||
results[responseName] = result; | ||
if (exeContext.signal?.aborted && !abortErrorThrown) { | ||
exeContext.errors.push(createGraphQLError('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: pathToArray(fieldPath), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
abortErrorThrown = true; | ||
} | ||
return results; | ||
@@ -281,8 +257,6 @@ }); | ||
let containsPromise = false; | ||
let abortErrorThrown = false; | ||
try { | ||
for (const [responseName, fieldNodes] of fields) { | ||
if (exeContext.signal?.aborted) { | ||
results[responseName] = null; | ||
continue; | ||
throw exeContext.signal.reason; | ||
} | ||
@@ -297,10 +271,2 @@ const fieldPath = addPath(path, responseName, parentType.name); | ||
} | ||
if (exeContext.signal?.aborted && !abortErrorThrown) { | ||
exeContext.errors.push(createGraphQLError('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: pathToArray(fieldPath), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
abortErrorThrown = true; | ||
} | ||
} | ||
@@ -503,7 +469,2 @@ } | ||
iterator.return?.(); | ||
exeContext.errors.push(createGraphQLError('Execution aborted', { | ||
nodes: fieldNodes, | ||
path: pathToArray(path), | ||
originalError: exeContext.signal?.reason, | ||
})); | ||
}); | ||
@@ -510,0 +471,0 @@ const errors = asyncPayloadRecord?.errors ?? exeContext.errors; |
@@ -12,3 +12,3 @@ /** | ||
signal?.addEventListener('abort', () => { | ||
resolve(); | ||
reject(signal.reason); | ||
}); | ||
@@ -15,0 +15,0 @@ Promise.all(Object.entries(object).map(async ([key, value]) => { |
{ | ||
"name": "@graphql-tools/executor", | ||
"version": "1.2.5-alpha-20240328134228-8452ac4e9c9e6970bfeb2ff7ab914352a0d7a646", | ||
"version": "1.2.5-alpha-20240328143324-239661c7f22ace5ca5539cc5b2e9f2e5fb67b38c", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "peerDependencies": { |
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
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
162374
3341