@@ -1095,7 +1095,6 @@ async function completeAsyncIteratorValue(
1095
1095
completeListItemValue (
1096
1096
iteration . value ,
1097
1097
completedResults ,
1098
- errors ,
1099
1098
exeContext ,
1100
1099
itemType ,
1101
1100
fieldNodes ,
@@ -1125,7 +1124,6 @@ function completeListValue(
1125
1124
asyncPayloadRecord ?: AsyncPayloadRecord ,
1126
1125
) : PromiseOrValue < ReadonlyArray < unknown > > {
1127
1126
const itemType = returnType . ofType ;
1128
- const errors = asyncPayloadRecord ?. errors ?? exeContext . errors ;
1129
1127
1130
1128
if ( isAsyncIterable ( result ) ) {
1131
1129
const iterator = result [ Symbol . asyncIterator ] ( ) ;
@@ -1189,7 +1187,6 @@ function completeListValue(
1189
1187
completeListItemValue (
1190
1188
item ,
1191
1189
completedResults ,
1192
- errors ,
1193
1190
exeContext ,
1194
1191
itemType ,
1195
1192
fieldNodes ,
@@ -1215,68 +1212,41 @@ function completeListValue(
1215
1212
function completeListItemValue (
1216
1213
item : unknown ,
1217
1214
completedResults : Array < unknown > ,
1218
- errors : Array < GraphQLError > ,
1219
1215
exeContext : ExecutionContext ,
1220
1216
itemType : GraphQLOutputType ,
1221
1217
fieldNodes : ReadonlyArray < FieldNode > ,
1222
1218
info : GraphQLResolveInfo ,
1223
1219
itemPath : Path ,
1224
1220
asyncPayloadRecord ?: AsyncPayloadRecord ,
1225
1221
) : boolean {
1226
- try {
1227
- let completedItem ;
1228
- if ( isPromise ( item ) ) {
1229
- completedItem = item . then ( ( resolved ) =>
1230
- completeValue (
1231
- exeContext ,
1232
- itemType ,
1233
- fieldNodes ,
1234
- info ,
1235
- itemPath ,
1236
- resolved ,
1237
- asyncPayloadRecord ,
1238
- ) ,
1239
- ) ;
1240
- } else {
1241
- completedItem = completeValue (
1222
+ if ( isPromise ( item ) ) {
1223
+ completedResults . push (
1224
+ completePromiseCatchingErrors (
1242
1225
exeContext ,
1243
1226
itemType ,
1244
1227
fieldNodes ,
1245
1228
info ,
1246
1229
itemPath ,
1247
1230
item ,
1248
1231
asyncPayloadRecord ,
1249
- ) ;
1250
- }
1251
-
1252
- if ( isPromise ( completedItem ) ) {
1253
- // Note: we don't rely on a `catch` method, but we do expect "thenable"
1254
- // to take a second callback for the error case.
1255
- completedResults . push (
1256
- completedItem . then ( undefined , ( rawError ) => {
1257
- const error = locatedError (
1258
- rawError ,
1259
- fieldNodes ,
1260
- pathToArray ( itemPath ) ,
1261
- ) ;
1262
- const handledError = handleFieldError ( error , itemType , errors ) ;
1263
- filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1264
- return handledError ;
1265
- } ) ,
1266
- ) ;
1232
+ ) ,
1233
+ ) ;
1234
+ return true ;
1235
+ }
1267
1236
1268
- return true ;
1269
- }
1237
+ const completed = completeValueCatchingErrors (
1238
+ exeContext ,
1239
+ itemType ,
1240
+ fieldNodes ,
1241
+ info ,
1242
+ itemPath ,
1243
+ item ,
1244
+ asyncPayloadRecord ,
1245
+ ) ;
1270
1246
1271
- completedResults . push ( completedItem ) ;
1272
- } catch ( rawError ) {
1273
- const error = locatedError ( rawError , fieldNodes , pathToArray ( itemPath ) ) ;
1274
- const handledError = handleFieldError ( error , itemType , errors ) ;
1275
- filterSubsequentPayloads ( exeContext , itemPath , asyncPayloadRecord ) ;
1276
- completedResults . push ( handledError ) ;
1277
- }
1247
+ completedResults . push ( completed ) ;
1278
1248
1279
- return false ;
1249
+ return isPromise ( completed ) ;
1280
1250
}
1281
1251
1282
1252
/**
0 commit comments