@@ -1091,7 +1091,6 @@ async function completeAsyncIteratorValue(
1091
1091
completeListItemValue (
1092
1092
iteration . value ,
1093
1093
completedResults ,
1094
- errors ,
1095
1094
exeContext ,
1096
1095
itemType ,
1097
1096
fieldNodes ,
@@ -1121,7 +1120,6 @@ function completeListValue(
1121
1120
asyncPayloadRecord ?: AsyncPayloadRecord ,
1122
1121
) : PromiseOrValue < ReadonlyArray < unknown > > {
1123
1122
const itemType = returnType . ofType ;
1124
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
1125
1123
1126
1124
if ( isAsyncIterable ( result ) ) {
1127
1125
const iterator = result [ Symbol . asyncIterator ] ( ) ;
@@ -1180,7 +1178,6 @@ function completeListValue(
1180
1178
completeListItemValue (
1181
1179
item ,
1182
1180
completedResults ,
1183
- errors ,
1184
1181
exeContext ,
1185
1182
itemType ,
1186
1183
fieldNodes ,
@@ -1206,68 +1203,41 @@ function completeListValue(
1206
1203
function completeListItemValue (
1207
1204
item : unknown ,
1208
1205
completedResults : Array < unknown > ,
1209
- errors : Array < GraphQLError > ,
1210
1206
exeContext : ExecutionContext ,
1211
1207
itemType : GraphQLOutputType ,
1212
1208
fieldNodes : ReadonlyArray < FieldNode > ,
1213
1209
info : GraphQLResolveInfo ,
1214
1210
itemPath : Path ,
1215
1211
asyncPayloadRecord ?: AsyncPayloadRecord ,
1216
1212
) : boolean {
1217
- try {
1218
- let completedItem ;
1219
- if ( isPromise ( item ) ) {
1220
- completedItem = item . then ( ( resolved ) =>
1221
- completeValue (
1222
- exeContext ,
1223
- itemType ,
1224
- fieldNodes ,
1225
- info ,
1226
- itemPath ,
1227
- resolved ,
1228
- asyncPayloadRecord ,
1229
- ) ,
1230
- ) ;
1231
- } else {
1232
- completedItem = completeValue (
1213
+ if ( isPromise ( item ) ) {
1214
+ completedResults . push (
1215
+ completePromiseCatchingErrors (
1233
1216
exeContext ,
1234
1217
itemType ,
1235
1218
fieldNodes ,
1236
1219
info ,
1237
1220
itemPath ,
1238
1221
item ,
1239
1222
asyncPayloadRecord ,
1240
- ) ;
1241
- }
1242
-
1243
- if ( isPromise ( completedItem ) ) {
1244
- // Note: we don't rely on a `catch` method, but we do expect "thenable"
1245
- // to take a second callback for the error case.
1246
- completedResults . push (
1247
- completedItem . then ( undefined , ( rawError ) => {
1248
- const error = locatedError (
1249
- rawError ,
1250
- fieldNodes ,
1251
- pathToArray ( itemPath ) ,
1252
- ) ;
1253
- const handledError = handleFieldError ( error , itemType , errors ) ;
1254
- filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1255
- return handledError ;
1256
- } ) ,
1257
- ) ;
1223
+ ) ,
1224
+ ) ;
1225
+ return true ;
1226
+ }
1258
1227
1259
- return true ;
1260
- }
1228
+ const completed = completeValueCatchingErrors (
1229
+ exeContext ,
1230
+ itemType ,
1231
+ fieldNodes ,
1232
+ info ,
1233
+ itemPath ,
1234
+ item ,
1235
+ asyncPayloadRecord ,
1236
+ ) ;
1261
1237
1262
- completedResults . push ( completedItem ) ;
1263
- } catch ( rawError ) {
1264
- const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1265
- const handledError = handleFieldError ( error , itemType , errors ) ;
1266
- filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1267
- completedResults . push ( handledError ) ;
1268
- }
1238
+ completedResults . push ( completed ) ;
1269
1239
1270
- return false ;
1240
+ return isPromise ( completed ) ;
1271
1241
}
1272
1242
1273
1243
/**
0 commit comments