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