Skip to content

Commit

Permalink
Remove location and path
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Oct 24, 2024
1 parent 84b122c commit aaa4190
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
20 changes: 1 addition & 19 deletions src/execution/__tests__/abort-signal-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'id'],
locations: [{ line: 4, column: 11 }],
},
],
});
Expand Down Expand Up @@ -149,8 +147,6 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'author', 'id'],
locations: [{ line: 6, column: 13 }],
},
],
});
Expand Down Expand Up @@ -198,8 +194,6 @@ describe('Execute: Cancellation', () => {
errors: [
{
message: 'Aborted',
path: ['todo', 'id'],
locations: [{ line: 4, column: 11 }],
},
],
});
Expand Down Expand Up @@ -261,14 +255,7 @@ describe('Execute: Cancellation', () => {
{
errors: [
{
locations: [
{
column: 13,
line: 6,
},
],
message: 'Aborted',
path: ['todo', 'text'],
},
],
id: '0',
Expand Down Expand Up @@ -304,15 +291,10 @@ describe('Execute: Cancellation', () => {
const result = await resultPromise;

expectJSON(result).toDeepEqual({
data: {
foo: 'baz',
bar: null,
},
data: null,
errors: [
{
message: 'Aborted',
path: ['bar'],
locations: [{ line: 4, column: 9 }],
},
],
});
Expand Down
28 changes: 10 additions & 18 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ export function validateExecutionArgs(
} = args;

if (abortSignal?.aborted) {
return [locatedError(new Error(abortSignal.reason), undefined)];
return [new GraphQLError(abortSignal.reason)];
}

// If the schema used for execution is invalid, throw an error.
Expand Down Expand Up @@ -667,16 +667,9 @@ function executeFieldsSerially(
const fieldPath = addPath(path, responseName, parentType.name);
const abortSignal = exeContext.validatedExecutionArgs.abortSignal;
if (abortSignal?.aborted) {
handleFieldError(
new Error(abortSignal.reason),
exeContext,
parentType,
fieldDetailsList,
fieldPath,
incrementalContext,
);
graphqlWrappedResult[0][responseName] = null;
return graphqlWrappedResult;
throw new GraphQLError(abortSignal.reason, {
path: undefined,
});
}

const result = executeField(
Expand Down Expand Up @@ -731,11 +724,9 @@ function executeFields(
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),
);
throw new GraphQLError(abortSignal.reason, {
path: undefined,
});
}

const result = executeField(
Expand Down Expand Up @@ -934,10 +925,11 @@ function handleFieldError(
path: Path,
incrementalContext: IncrementalContext | undefined,
): void {
const isAborted = exeContext.validatedExecutionArgs.abortSignal?.aborted;
const error = locatedError(
rawError,
toNodes(fieldDetailsList),
pathToArray(path),
isAborted ? undefined : toNodes(fieldDetailsList),
isAborted ? undefined : pathToArray(path),
);

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

0 comments on commit aaa4190

Please sign in to comment.