Skip to content

Commit c4fe200

Browse files
committed
Address @leebyron review comments
1 parent 3802af7 commit c4fe200

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/execution/execute.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -812,19 +812,23 @@ function completeValueCatchingError(
812812
if (isPromise(completed)) {
813813
// Note: we don't rely on a `catch` method, but we do expect "thenable"
814814
// to take a second callback for the error case.
815-
return completed.then(undefined, rawError => {
816-
const error = locatedFieldError(rawError, fieldNodes, path);
817-
return handleFieldError(error, returnType, exeContext);
818-
});
815+
return completed.then(undefined, error =>
816+
handleFieldError(error, fieldNodes, path, returnType, exeContext),
817+
);
819818
}
820819
return completed;
821-
} catch (rawError) {
822-
const error = locatedFieldError(rawError, fieldNodes, path);
823-
return handleFieldError(error, returnType, exeContext);
820+
} catch (error) {
821+
return handleFieldError(error, fieldNodes, path, returnType, exeContext);
824822
}
825823
}
826824

827-
function handleFieldError(error, returnType, exeContext) {
825+
function handleFieldError(rawError, fieldNodes, path, returnType, exeContext) {
826+
const error = locatedError(
827+
asErrorInstance(rawError),
828+
fieldNodes,
829+
responsePathAsArray(path),
830+
);
831+
828832
// If the field type is non-nullable, then it is resolved without any
829833
// protection from errors, however it still properly locates the error.
830834
if (isNonNullType(returnType)) {
@@ -837,11 +841,6 @@ function handleFieldError(error, returnType, exeContext) {
837841
return null;
838842
}
839843

840-
function locatedFieldError(errorValue, fieldNodes, path) {
841-
const error = asErrorInstance(errorValue);
842-
return locatedError(error, fieldNodes, responsePathAsArray(path));
843-
}
844-
845844
/**
846845
* Implements the instructions for completeValue as defined in the
847846
* "Field entries" section of the spec.

0 commit comments

Comments
 (0)