Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove location and path #4252

Closed
wants to merge 1 commit into from
Closed
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
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
Loading