@@ -897,12 +897,34 @@ function completeListValue(
897897 ) ;
898898 }
899899
900+ return completeIterableValue (
901+ exeContext ,
902+ itemType ,
903+ fieldGroup ,
904+ info ,
905+ path ,
906+ result ,
907+ ) ;
908+ }
909+
910+ function completeIterableValue (
911+ exeContext : ExecutionContext ,
912+ itemType : GraphQLOutputType ,
913+ fieldGroup : FieldGroup ,
914+ info : GraphQLResolveInfo ,
915+ path : Path ,
916+ items : Iterable < unknown > ,
917+ ) : PromiseOrValue < ReadonlyArray < unknown > > {
900918 // This is specified as a simple map, however we're optimizing the path
901919 // where the list contains no Promises by avoiding creating another Promise.
902920 let containsPromise = false ;
903921 const completedResults : Array < unknown > = [ ] ;
904922 let index = 0 ;
905- for ( const item of result ) {
923+ const iterator = items [ Symbol . iterator ] ( ) ;
924+ let iteration = iterator . next ( ) ;
925+ while ( ! iteration . done ) {
926+ const item = iteration . value ;
927+
906928 // No need to modify the info object containing the path,
907929 // since from here on it is not ever accessed by resolver functions.
908930 const itemPath = addPath ( path , index , undefined ) ;
@@ -934,6 +956,7 @@ function completeListValue(
934956 }
935957
936958 index ++ ;
959+ iteration = iterator . next ( ) ;
937960 }
938961
939962 return containsPromise ? Promise . all ( completedResults ) : completedResults ;
0 commit comments