@@ -866,12 +866,34 @@ function completeListValue(
866866 ) ;
867867 }
868868
869+ return completeIterableValue (
870+ exeContext ,
871+ itemType ,
872+ fieldGroup ,
873+ info ,
874+ path ,
875+ result ,
876+ ) ;
877+ }
878+
879+ function completeIterableValue (
880+ exeContext : ExecutionContext ,
881+ itemType : GraphQLOutputType ,
882+ fieldGroup : FieldGroup ,
883+ info : GraphQLResolveInfo ,
884+ path : Path ,
885+ items : Iterable < unknown > ,
886+ ) : PromiseOrValue < ReadonlyArray < unknown > > {
869887 // This is specified as a simple map, however we're optimizing the path
870888 // where the list contains no Promises by avoiding creating another Promise.
871889 let containsPromise = false ;
872890 const completedResults : Array < unknown > = [ ] ;
873891 let index = 0 ;
874- for ( const item of result ) {
892+ const iterator = items [ Symbol . iterator ] ( ) ;
893+ let iteration = iterator . next ( ) ;
894+ while ( ! iteration . done ) {
895+ const item = iteration . value ;
896+
875897 // No need to modify the info object containing the path,
876898 // since from here on it is not ever accessed by resolver functions.
877899 const itemPath = addPath ( path , index , undefined ) ;
@@ -903,6 +925,7 @@ function completeListValue(
903925 }
904926
905927 index ++ ;
928+ iteration = iterator . next ( ) ;
906929 }
907930
908931 return containsPromise ? Promise . all ( completedResults ) : completedResults ;
0 commit comments