@@ -703,16 +703,14 @@ function executeField(
703
703
704
704
result = resolveFn ( source , args , contextValue , info ) ;
705
705
} catch ( rawError ) {
706
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
707
- const handledError = addError (
706
+ return handleRawError (
708
707
rawError ,
708
+ exeContext ,
709
709
fieldNodes ,
710
710
returnType ,
711
711
path ,
712
- errors ,
712
+ asyncPayloadRecord ,
713
713
) ;
714
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
715
- return handledError ;
716
714
}
717
715
718
716
if ( isPromise ( result ) ) {
@@ -765,6 +763,20 @@ export function buildResolveInfo(
765
763
} ;
766
764
}
767
765
766
+ function handleRawError (
767
+ rawError : unknown ,
768
+ exeContext : ExecutionContext ,
769
+ fieldNodes : ReadonlyArray < FieldNode > ,
770
+ returnType : GraphQLOutputType ,
771
+ path : Path ,
772
+ asyncPayloadRecord : AsyncPayloadRecord | undefined ,
773
+ ) : null {
774
+ const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
775
+ addError ( rawError , fieldNodes , returnType , path , errors ) ;
776
+ filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
777
+ return null ;
778
+ }
779
+
768
780
function addError (
769
781
rawError : unknown ,
770
782
fieldNodes : ReadonlyArray < FieldNode > ,
@@ -926,16 +938,14 @@ async function completePromiseCatchingErrors(
926
938
}
927
939
return completed ;
928
940
} catch ( rawError ) {
929
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
930
- const handledError = addError (
941
+ return handleRawError (
931
942
rawError ,
943
+ exeContext ,
932
944
fieldNodes ,
933
945
returnType ,
934
946
path ,
935
- errors ,
947
+ asyncPayloadRecord ,
936
948
) ;
937
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
938
- return handledError ;
939
949
}
940
950
}
941
951
@@ -960,16 +970,14 @@ function completeValueCatchingErrors(
960
970
asyncPayloadRecord ,
961
971
) ;
962
972
} catch ( rawError ) {
963
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
964
- const handledError = addError (
973
+ return handleRawError (
965
974
rawError ,
975
+ exeContext ,
966
976
fieldNodes ,
967
977
returnType ,
968
978
path ,
969
- errors ,
979
+ asyncPayloadRecord ,
970
980
) ;
971
- filterSubsequentPayloads ( exeContext , path , asyncPayloadRecord ) ;
972
- return handledError ;
973
981
}
974
982
975
983
if ( isPromise ( completedValue ) ) {
0 commit comments