Skip to content

Commit 88c5d93

Browse files
committed
Simplify
1 parent 8fcacc8 commit 88c5d93

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/execution/execute.ts

+5-22
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,9 @@ function completeValue(
668668
throw result;
669669
}
670670

671-
// If field type is NonNull, complete for inner type, and throw field error
671+
// If field type is non-nullable, complete for inner type, and throw field error
672672
// if result is null.
673-
if (isNonNullType(returnType)) {
673+
if (isNonNullType(returnType) || isSemanticNonNullType(returnType)) {
674674
const completed = completeValue(
675675
exeContext,
676676
returnType.ofType,
@@ -681,26 +681,9 @@ function completeValue(
681681
);
682682
if (completed === null) {
683683
throw new Error(
684-
`Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`,
685-
);
686-
}
687-
return completed;
688-
}
689-
690-
// If field type is SemanticNonNull, complete for inner type, and throw field error
691-
// if result is null.
692-
if (isSemanticNonNullType(returnType)) {
693-
const completed = completeValue(
694-
exeContext,
695-
returnType.ofType,
696-
fieldNodes,
697-
info,
698-
path,
699-
result,
700-
);
701-
if (completed === null) {
702-
throw new Error(
703-
`Cannot return null for semantic-non-nullable field ${info.parentType.name}.${info.fieldName}.`,
684+
`Cannot return null for ${
685+
isSemanticNonNullType(returnType) ? 'semantically ' : ''
686+
}non-nullable field ${info.parentType.name}.${info.fieldName}.`,
704687
);
705688
}
706689
return completed;

0 commit comments

Comments
 (0)