Skip to content

Commit 0a99246

Browse files
committed
Extract locatedFieldError function
1 parent 8e57173 commit 0a99246

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/execution/execute.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -813,31 +813,23 @@ function completeValueCatchingError(
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.
815815
return completed.then(undefined, rawError => {
816-
const error = locatedError(
817-
asErrorInstance(rawError),
818-
fieldNodes,
819-
responsePathAsArray(path),
820-
);
816+
const error = locatedFieldError(rawError, fieldNodes, path);
821817

822818
// If the field type is non-nullable, then it is resolved without any
823819
// protection from errors, however it still properly locates the error.
824820
if (isNonNullType(returnType)) {
825821
throw error;
826822
}
827823

828-
// Otherwise, error protection is applied, logging the error and resolving
829-
// a null value for this field if one is encountered.
824+
// Otherwise, error protection is applied, logging the error and
825+
// resolving a null value for this field if one is encountered.
830826
exeContext.errors.push(error);
831827
return null;
832828
});
833829
}
834830
return completed;
835831
} catch (rawError) {
836-
const error = locatedError(
837-
asErrorInstance(rawError),
838-
fieldNodes,
839-
responsePathAsArray(path),
840-
);
832+
const error = locatedFieldError(rawError, fieldNodes, path);
841833

842834
// If the field type is non-nullable, then it is resolved without any
843835
// protection from errors, however it still properly locates the error.
@@ -852,6 +844,11 @@ function completeValueCatchingError(
852844
}
853845
}
854846

847+
function locatedFieldError(errorValue, fieldNodes, path) {
848+
const error = asErrorInstance(errorValue);
849+
return locatedError(error, fieldNodes, responsePathAsArray(path));
850+
}
851+
855852
/**
856853
* Implements the instructions for completeValue as defined in the
857854
* "Field entries" section of the spec.

0 commit comments

Comments
 (0)