@@ -856,14 +856,19 @@ function completeValueCatchingError(
856
856
// If the field type is non-nullable, then it is resolved without any
857
857
// protection from errors, however it still properly locates the error.
858
858
if ( isNonNullType ( returnType ) ) {
859
- return completeValueWithLocatedError (
859
+ const completed = completeValueWithLocatedError (
860
860
exeContext ,
861
861
returnType ,
862
862
fieldNodes ,
863
863
info ,
864
864
path ,
865
865
result ,
866
866
) ;
867
+ const promise = getPromise ( completed ) ;
868
+ if ( promise ) {
869
+ return promise . then ( r => r . data ) ;
870
+ }
871
+ return completed . data ;
867
872
}
868
873
869
874
// Otherwise, error protection is applied, logging the error and resolving
@@ -883,12 +888,12 @@ function completeValueCatchingError(
883
888
// the rejection error and resolve to null.
884
889
// Note: we don't rely on a `catch` method, but we do expect "thenable"
885
890
// to take a second callback for the error case.
886
- return promise . then ( undefined , error => {
891
+ return promise . then ( r => r . data ) . then ( undefined , error => {
887
892
exeContext . errors . push ( error ) ;
888
893
return null ;
889
894
} ) ;
890
895
}
891
- return completed ;
896
+ return completed . data ;
892
897
} catch ( error ) {
893
898
// If `completeValueWithLocatedError` returned abruptly (threw an error),
894
899
// log the error and return null.
@@ -906,7 +911,7 @@ function completeValueWithLocatedError(
906
911
info: GraphQLResolveInfo,
907
912
path: ResponsePath,
908
913
result: mixed,
909
- ): mixed {
914
+ ): ExecutionPartialResult < mixed > {
910
915
try {
911
916
const completed = completeValue (
912
917
exeContext ,
@@ -918,7 +923,7 @@ function completeValueWithLocatedError(
918
923
) ;
919
924
const promise = getPromise ( completed ) ;
920
925
if ( promise ) {
921
- return promise . then ( r => r . data ) . then ( undefined , error =>
926
+ return promise . then ( undefined , error =>
922
927
Promise . reject (
923
928
locatedError (
924
929
asErrorInstance ( error ) ,
@@ -928,7 +933,7 @@ function completeValueWithLocatedError(
928
933
) ,
929
934
) ;
930
935
}
931
- return completed . data ;
936
+ return completed ;
932
937
} catch (error) {
933
938
throw locatedError (
934
939
asErrorInstance ( error ) ,
0 commit comments