@@ -1032,7 +1032,26 @@ function completeAsyncIteratorValue(
1032
1032
let containsPromise = false ;
1033
1033
const stream = getStreamValues ( exeContext , fieldNodes ) ;
1034
1034
return new Promise ( ( resolve ) => {
1035
- function next ( index , completedResults ) {
1035
+ function advance ( index , completedResults ) {
1036
+ if (
1037
+ stream &&
1038
+ typeof stream . initialCount === 'number' &&
1039
+ index >= stream . initialCount
1040
+ ) {
1041
+ exeContext . dispatcher . addAsyncIteratorValue (
1042
+ stream . label ,
1043
+ index ,
1044
+ path ,
1045
+ iterator ,
1046
+ exeContext ,
1047
+ fieldNodes ,
1048
+ info ,
1049
+ itemType ,
1050
+ ) ;
1051
+ resolve ( completedResults ) ;
1052
+ return ;
1053
+ }
1054
+
1036
1055
const fieldPath = addPath ( path , index , undefined ) ;
1037
1056
iterator . next ( ) . then (
1038
1057
( { value, done } ) => {
@@ -1067,26 +1086,7 @@ function completeAsyncIteratorValue(
1067
1086
return ;
1068
1087
}
1069
1088
1070
- const newIndex = index + 1 ;
1071
- if (
1072
- stream &&
1073
- typeof stream . initialCount === 'number' &&
1074
- newIndex >= stream . initialCount
1075
- ) {
1076
- exeContext . dispatcher . addAsyncIteratorValue (
1077
- stream . label ,
1078
- newIndex ,
1079
- path ,
1080
- iterator ,
1081
- exeContext ,
1082
- fieldNodes ,
1083
- info ,
1084
- itemType ,
1085
- ) ;
1086
- resolve ( completedResults ) ;
1087
- return ;
1088
- }
1089
- next ( newIndex , completedResults ) ;
1089
+ advance ( index + 1 , completedResults ) ;
1090
1090
} ,
1091
1091
( rawError ) => {
1092
1092
completedResults . push ( null ) ;
@@ -1100,7 +1100,8 @@ function completeAsyncIteratorValue(
1100
1100
} ,
1101
1101
) ;
1102
1102
}
1103
- next ( 0 , [ ] ) ;
1103
+
1104
+ advance ( 0 , [ ] ) ;
1104
1105
} ) . then ( ( completedResults ) =>
1105
1106
containsPromise ? Promise . all ( completedResults ) : completedResults ,
1106
1107
) ;
0 commit comments