@@ -726,13 +726,29 @@ serial):
726
726
- Let {initialFuture} be the future result of
727
727
{ExecuteInitialResult(variableValues, initialValue, objectType, selectionSet,
728
728
serial)}.
729
- - Initialize {pendingResults}, {pendingFutures}, and {unsent} to the empty set.
729
+ - Initiate {initialFuture}.
730
+ - Initialize {pendingFutures} to a set containing {initialFuture}.
731
+ - Initialize {pendingResults} {pendingFutures}, and {unsent} to the empty set.
730
732
- Initialize {newPendingResultsByFragment}, {pendingFuturesByFragment}, and
731
733
{completedFuturesByFragment} to empty unordered maps.
732
734
- Repeat the following steps:
733
- - Initialize {pending}, {incremental}, and {completed} to empty lists.
734
- - Wait for any futures within {pendingFutures} to complete.
735
- - Let {completedFutures} be those completed futures.
735
+ - If none of the futures in {pendingFutures} have completed:
736
+ - If {incremental} or {completed} is not empty:
737
+ - If {pendingResults} is empty, let {hasNext} be {false}, otherwise let it
738
+ be {true}.
739
+ - Let {incrementalResult} be a new unordered map containing {pending},
740
+ {incremental}, {completed} and {hasNext}.
741
+ - Yield {incrementalResult}.
742
+ - If {hasNext} is {false}, complete this incremental result stream and
743
+ return.
744
+ - For each {future} in {newFutures}:
745
+ - Initialize {future} if it has not yet been initialized.
746
+ - Add {future} to {pendingFutures}.
747
+ - Reset {newFutures} to the empty set.
748
+ - Reset {pending}, {incremental}, and {completed} to empty lists.
749
+ - Wait for any futures within {pendingFutures} to complete.
750
+ - Let {completedFutures} be the futures in {pendingFutures} that have
751
+ completed.
736
752
- For each {future} in {completedFutures}:
737
753
- Remove {future} from {pendingFutures}.
738
754
- Let {result} be the result of {future}.
@@ -778,12 +794,12 @@ serial):
778
794
in {pendingFuturesByFragment}.
779
795
- If the size of {completedFuturesForFragment} is equal to the size of
780
796
{pendingFuturesForFragment}:
781
- - Let {fragmentPendingFutures }, {fragmentPending},
797
+ - Let {fragmentNewFutures }, {fragmentPending},
782
798
{fragmentIncremental}, and {fragmentCompleted}, be the result of
783
799
{CompleteFragment(deferredFragment, completedFuturesForFragment,
784
800
pendingFuturesForFragment, newPendingResultsByFragment,
785
801
completedFuturesByFragment, unsent)}.
786
- - Add all items in {fragmentPendingFutures } to {pendingFutures }.
802
+ - Add all items in {fragmentNewFutures } to {newFutures }.
787
803
- For each {pendingResult} in {fragmentPending}:
788
804
- Append {pendingResult} to {pending}.
789
805
- Add {pendingResult} to {pendingResults}.
@@ -796,10 +812,9 @@ serial):
796
812
- For each {result} in {incremental}:
797
813
- Let {newPendingResults} and {futures} be the corresponding entries on
798
814
{incremental}.
799
- - For each {future} of {futures}:
800
- - If {future} represents completion of Stream Items:
801
- - Initiate {future} if it has not yet been initiated.
802
- - Add {future} to {pendingFutures}.
815
+ - For each {future} of {futures}: If {future} represents completion of
816
+ Stream Items:
817
+ - Add {future} to {newFutures}.
803
818
- Otherwise:
804
819
- Let {deferredFragments} be the Deferred Fragments completed by
805
820
{future}.
@@ -809,8 +824,7 @@ serial):
809
824
exists, create it as an empty list.
810
825
- Append {future} to {pendingFuturesForFragment}.
811
826
- If {deferredFragment} is contained by {pendingResults}:
812
- - Initiate {future} if it has not yet been initiated.
813
- - Add {future} to {pendingFutures}.
827
+ - Add {future} to {newFutures}.
814
828
- For each {newPendingResult} of {newPendingResults}:
815
829
- If {newPendingResult} represents a Stream:
816
830
- Append {newPendingResult} to {pending}.
@@ -825,25 +839,12 @@ serial):
825
839
- Append {newPendingResult} to {pending}.
826
840
- Add {newPendingResult} to {pendingResults}.
827
841
- For each {future} in {pendingFuturesForFragment}:
828
- - Initiate {future} if it has not yet been initiated.
829
- - Add {future} to {pendingFutures}.
842
+ - Add {future} to {newFutures}.
830
843
- Otherwise:
831
844
- Let {newPendingResultsForFragment} be the entry for {parent} in
832
845
{newPendingResultsByFragment}; if no such list exists, create it
833
846
as an empty list.
834
847
- Append {newPendingResult} to {newPendingResultsForFragment}.
835
- - If {pendingResults} is empty, let {hasNext} be {false}, otherwise let it
836
- be {true}.
837
- - If {data} is defined:
838
- - Let {incrementalResult} be a new unordered map containing {data},
839
- {errors} and {pending}.
840
- - Yield {incrementalResult}.
841
- - Otherwise, if {incremental} or {completed} is not empty:
842
- - Let {incrementalResult} be a new unordered map containing {pending},
843
- {incremental}, {completed} and {hasNext}.
844
- - Yield {incrementalResult}.
845
- - If {hasNext} is {false}, complete this incremental result stream and
846
- return.
847
848
848
849
ExecuteInitialResult(variableValues, initialValue, objectType, selectionSet,
849
850
serial):
@@ -865,7 +866,7 @@ CompleteFragment(deferredFragment, completedFuturesForFragment,
865
866
pendingFuturesForFragment, newPendingResultsByFragment,
866
867
completedFuturesByFragment, unsent):
867
868
868
- - Initialize {pendingFutures } to the empty set.
869
+ - Initialize {newFutures } to the empty set.
869
870
- Initialize {pending}, {incremental}, and {completed} to empty lists.
870
871
- Let {completedEntry} be an empty unordered map.
871
872
- Set the entry for {pendingResult} on {completedEntry} to {deferredFragment}.
@@ -889,16 +890,15 @@ completedFuturesByFragment, unsent):
889
890
{fragmentCompleted}, be the result of {CompleteFragment(deferredFragment,
890
891
resultsForFragment, pendingFuturesForFragment,
891
892
newPendingResultsByFragment, resultsByFragment, unsent)}.
892
- - Add all items in {fragmentPendingFutures } to {pendingFutures }.
893
+ - Add all items in {fragmentNewFutures } to {newFutures }.
893
894
- Append all items in {fragmentPending} to {pending}.
894
895
- Append all items in {fragmentIncremental} to {incremental}.
895
896
- Append all items in {fragmentCompleted} to {completed}.
896
897
- Otherwise:
897
898
- For each {future} in {fragmentPendingFuturesForFragment}:
898
899
- If {completedFuturesForFragment} does not contain {future}:
899
- - Initiate {future} if it has not yet been initiated.
900
- - Add {future} to {pendingFutures}.
901
- - Return {pendingFutures}, {pending}, {incremental}, and {completed}.
900
+ - Add {future} to {newFutures}.
901
+ - Return {newFutures}, {pending}, {incremental}, and {completed}.
902
902
903
903
## Executing a Field Plan
904
904
0 commit comments