Skip to content

Commit edcc44a

Browse files
committed
Remove location and path
1 parent 84b122c commit edcc44a

File tree

2 files changed

+11
-37
lines changed

2 files changed

+11
-37
lines changed

src/execution/__tests__/abort-signal-test.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ describe('Execute: Cancellation', () => {
100100
errors: [
101101
{
102102
message: 'Aborted',
103-
path: ['todo', 'id'],
104-
locations: [{ line: 4, column: 11 }],
105103
},
106104
],
107105
});
@@ -149,8 +147,6 @@ describe('Execute: Cancellation', () => {
149147
errors: [
150148
{
151149
message: 'Aborted',
152-
path: ['todo', 'author', 'id'],
153-
locations: [{ line: 6, column: 13 }],
154150
},
155151
],
156152
});
@@ -198,8 +194,6 @@ describe('Execute: Cancellation', () => {
198194
errors: [
199195
{
200196
message: 'Aborted',
201-
path: ['todo', 'id'],
202-
locations: [{ line: 4, column: 11 }],
203197
},
204198
],
205199
});
@@ -261,14 +255,7 @@ describe('Execute: Cancellation', () => {
261255
{
262256
errors: [
263257
{
264-
locations: [
265-
{
266-
column: 13,
267-
line: 6,
268-
},
269-
],
270258
message: 'Aborted',
271-
path: ['todo', 'text'],
272259
},
273260
],
274261
id: '0',
@@ -304,15 +291,10 @@ describe('Execute: Cancellation', () => {
304291
const result = await resultPromise;
305292

306293
expectJSON(result).toDeepEqual({
307-
data: {
308-
foo: 'baz',
309-
bar: null,
310-
},
294+
data: null,
311295
errors: [
312296
{
313297
message: 'Aborted',
314-
path: ['bar'],
315-
locations: [{ line: 4, column: 9 }],
316298
},
317299
],
318300
});

src/execution/execute.ts

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ export function validateExecutionArgs(
518518
} = args;
519519

520520
if (abortSignal?.aborted) {
521-
return [locatedError(new Error(abortSignal.reason), undefined)];
521+
return [new GraphQLError((abortSignal.reason as string) || 'Aborted')];
522522
}
523523

524524
// If the schema used for execution is invalid, throw an error.
@@ -667,16 +667,9 @@ function executeFieldsSerially(
667667
const fieldPath = addPath(path, responseName, parentType.name);
668668
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
669669
if (abortSignal?.aborted) {
670-
handleFieldError(
671-
new Error(abortSignal.reason),
672-
exeContext,
673-
parentType,
674-
fieldDetailsList,
675-
fieldPath,
676-
incrementalContext,
677-
);
678-
graphqlWrappedResult[0][responseName] = null;
679-
return graphqlWrappedResult;
670+
throw new GraphQLError((abortSignal.reason as string) || 'Aborted', {
671+
path: undefined,
672+
});
680673
}
681674

682675
const result = executeField(
@@ -731,11 +724,9 @@ function executeFields(
731724
const fieldPath = addPath(path, responseName, parentType.name);
732725
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
733726
if (abortSignal?.aborted) {
734-
throw locatedError(
735-
new Error(abortSignal.reason),
736-
toNodes(fieldDetailsList),
737-
pathToArray(fieldPath),
738-
);
727+
throw new GraphQLError((abortSignal.reason as string) || 'Aborted', {
728+
path: undefined,
729+
});
739730
}
740731

741732
const result = executeField(
@@ -934,10 +925,11 @@ function handleFieldError(
934925
path: Path,
935926
incrementalContext: IncrementalContext | undefined,
936927
): void {
928+
const isAborted = exeContext.validatedExecutionArgs.abortSignal?.aborted;
937929
const error = locatedError(
938930
rawError,
939-
toNodes(fieldDetailsList),
940-
pathToArray(path),
931+
isAborted ? undefined : toNodes(fieldDetailsList),
932+
isAborted ? undefined : pathToArray(path),
941933
);
942934

943935
// If the field type is non-nullable, then it is resolved without any

0 commit comments

Comments
 (0)