Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/execution/__tests__/abort-signal-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'id'],
locations: [{ line: 4, column: 11 }],
path: ['todo'],
locations: [{ line: 3, column: 9 }],
},
],
});
Expand Down Expand Up @@ -149,8 +149,8 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'author', 'id'],
locations: [{ line: 6, column: 13 }],
path: ['todo', 'author'],
locations: [{ line: 5, column: 11 }],
},
],
});
Expand Down Expand Up @@ -198,8 +198,8 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'id'],
locations: [{ line: 4, column: 11 }],
path: ['todo'],
locations: [{ line: 3, column: 9 }],
},
],
});
Expand Down Expand Up @@ -257,23 +257,28 @@ describe('Execute: Cancellation', () => {
hasNext: true,
},
{
completed: [
incremental: [
{
data: {
text: 'hello world',
author: null,
},
errors: [
{
locations: [
{
column: 13,
line: 6,
line: 7,
},
],
message: 'Aborted',
path: ['todo', 'text'],
path: ['todo', 'author'],
},
],
id: '0',
},
],
completed: [{ id: '0' }],
hasNext: false,
},
]);
Expand Down
21 changes: 11 additions & 10 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -729,15 +729,6 @@ function executeFields(
try {
for (const [responseName, fieldDetailsList] of groupedFieldSet) {
const fieldPath = addPath(path, responseName, parentType.name);
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
if (abortSignal?.aborted) {
throw locatedError(
new Error(abortSignal.reason),
toNodes(fieldDetailsList),
pathToArray(fieldPath),
);
}

const result = executeField(
exeContext,
parentType,
Expand Down Expand Up @@ -1737,13 +1728,23 @@ function completeObjectValue(
incrementalContext: IncrementalContext | undefined,
deferMap: ReadonlyMap<DeferUsage, DeferredFragmentRecord> | undefined,
): PromiseOrValue<GraphQLWrappedResult<ObjMap<unknown>>> {
const validatedExecutionArgs = exeContext.validatedExecutionArgs;
const abortSignal = validatedExecutionArgs.abortSignal;
if (abortSignal?.aborted) {
throw locatedError(
new Error(abortSignal.reason),
toNodes(fieldDetailsList),
pathToArray(path),
);
}

// If there is an isTypeOf predicate function, call it with the
// current result. If isTypeOf returns false, then raise an error rather
// than continuing execution.
if (returnType.isTypeOf) {
const isTypeOf = returnType.isTypeOf(
result,
exeContext.validatedExecutionArgs.contextValue,
validatedExecutionArgs.contextValue,
info,
);

Expand Down
Loading