Skip to content

Commit dc41871

Browse files
committed
remove helper
1 parent 88c48c9 commit dc41871

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

src/execution/execute.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
394394
exeContext.abortSignalListener?.disconnect();
395395
return {
396396
data: null,
397-
errors: addError(exeContext.errors, error as GraphQLError),
397+
errors: [...exeContext.errors, error as GraphQLError],
398398
};
399399
},
400400
);
@@ -406,18 +406,10 @@ export function experimentalExecuteQueryOrMutationOrSubscriptionEvent(
406406
// TODO: add test case for synchronous null bubbling to root with cancellation
407407
/* c8 ignore next */
408408
exeContext.abortSignalListener?.disconnect();
409-
return { data: null, errors: addError(exeContext.errors, error) };
409+
return { data: null, errors: [...exeContext.errors, error] };
410410
}
411411
}
412412

413-
function addError(
414-
errors: Array<GraphQLError>,
415-
error: GraphQLError,
416-
): ReadonlyArray<GraphQLError> {
417-
errors.push(error);
418-
return errors;
419-
}
420-
421413
function buildDataResponse(
422414
exeContext: ExecutionContext,
423415
graphqlWrappedResult: GraphQLWrappedResult<ObjMap<unknown>>,
@@ -1006,7 +998,7 @@ function handleFieldError(
1006998
// Otherwise, error protection is applied, logging the error and resolving
1007999
// a null value for this field if one is encountered.
10081000
const context = incrementalContext ?? exeContext;
1009-
addError(context.errors, error);
1001+
context.errors.push(error);
10101002
}
10111003

10121004
/**
@@ -2458,7 +2450,7 @@ function executeExecutionGroup(
24582450
return {
24592451
pendingExecutionGroup,
24602452
path: pathToArray(path),
2461-
errors: addError(incrementalContext.errors, error),
2453+
errors: [...incrementalContext.errors, error],
24622454
};
24632455
}
24642456

@@ -2478,7 +2470,7 @@ function executeExecutionGroup(
24782470
return {
24792471
pendingExecutionGroup,
24802472
path: pathToArray(path),
2481-
errors: addError(incrementalContext.errors, error as GraphQLError),
2473+
errors: [...incrementalContext.errors, error as GraphQLError],
24822474
};
24832475
},
24842476
);
@@ -2720,7 +2712,7 @@ function completeStreamItem(
27202712
(error: unknown) => {
27212713
incrementalContext.completed = true;
27222714
return {
2723-
errors: addError(incrementalContext.errors, error as GraphQLError),
2715+
errors: [...incrementalContext.errors, error as GraphQLError],
27242716
};
27252717
},
27262718
);
@@ -2753,7 +2745,7 @@ function completeStreamItem(
27532745
} catch (error) {
27542746
incrementalContext.completed = true;
27552747
return {
2756-
errors: addError(incrementalContext.errors, error),
2748+
errors: [...incrementalContext.errors, error],
27572749
};
27582750
}
27592751

@@ -2778,7 +2770,7 @@ function completeStreamItem(
27782770
(error: unknown) => {
27792771
incrementalContext.completed = true;
27802772
return {
2781-
errors: addError(incrementalContext.errors, error as GraphQLError),
2773+
errors: [...incrementalContext.errors, error as GraphQLError],
27822774
};
27832775
},
27842776
);

0 commit comments

Comments
 (0)