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