@@ -380,21 +380,13 @@ YieldSubsequentPayloads(subsequentPayloads):
380
380
- While {subsequentPayloads} is not empty:
381
381
- If a termination signal is received:
382
382
- For each {record} in {subsequentPayloads}:
383
- - If {record} is a Stream Record:
384
- - Let {iterator} be the correspondent fields on the Stream Record
385
- structure.
383
+ - If {record} contains {iterator}:
386
384
- Send a termination signal to {iterator}.
387
385
- Return.
388
- - Let {record} be the first complete item in {subsequentPayloads}.
386
+ - Let {record} be the first item in {subsequentPayloads} with a completed
387
+ {dataExecution}.
389
388
- Remove {record} from {subsequentPayloads}.
390
- - Assert: {record} must be a Deferred Fragment Record or a Stream Record.
391
- - If {record} is a Deferred Fragment Record:
392
- - Let {payload} be the result of running
393
- {ResolveDeferredFragmentRecord(record, variableValues,
394
- subsequentPayloads)}.
395
- - If {record} is a Stream Record:
396
- - Let {payload} be the result of running {ResolveStreamRecord(record,
397
- variableValues, subsequentPayloads)}.
389
+ - Let {payload} be the completed result returned by {dataExecution}.
398
390
- If {payload} is {null}:
399
391
- If {subsequentPayloads} is empty:
400
392
- Yield a map containing a field ` hasNext ` with the value {false}.
@@ -626,10 +618,9 @@ subsequentPayloads, asyncRecord, visitedFragments):
626
618
- If {deferDirective} is defined:
627
619
- Let {label} be the value or the variable to {deferDirective}'s {label}
628
620
argument.
629
- - Let {deferredFragmentRecord} be the result of calling
630
- {CreateDeferredFragmentRecord(label, objectType, objectValue,
631
- fragmentSelectionSet, path, asyncRecord)}.
632
- - Append {deferredFragmentRecord} to {subsequentPayloads}.
621
+ - Call {ExecuteDeferredFragment(label, objectType, objectValue,
622
+ fragmentSelectionSet, path, variableValues, asyncRecord,
623
+ subsequentPayloads)}.
633
624
- Continue with the next {selection} in {selectionSet}.
634
625
- Let {fragmentGroupedFieldSet} be the result of calling
635
626
{CollectFields(objectType, objectValue, fragmentSelectionSet,
@@ -652,10 +643,8 @@ subsequentPayloads, asyncRecord, visitedFragments):
652
643
{variableValues} with the value {true}:
653
644
- Let {label} be the value or the variable to {deferDirective}'s {label}
654
645
argument.
655
- - Let {deferredFragmentRecord} be the result of calling
656
- {CreateDeferredFragmentRecord(label, objectType, objectValue,
657
- fragmentSelectionSet, path, asyncRecord)}.
658
- - Append {deferredFragmentRecord} to {subsequentPayloads}.
646
+ - Call {ExecuteDeferredFragment(label, objectType, objectValue,
647
+ fragmentSelectionSet, path, asyncRecord, subsequentPayloads)}.
659
648
- Continue with the next {selection} in {selectionSet}.
660
649
- Let {fragmentGroupedFieldSet} be the result of calling
661
650
{CollectFields(objectType, objectValue, fragmentSelectionSet,
@@ -689,50 +678,31 @@ An Async Payload Record is either a Deferred Fragment Record or a Stream Record.
689
678
All Async Payload Records are structures containing:
690
679
691
680
- {label}: value derived from the corresponding ` @defer ` or ` @stream ` directive.
692
- - {parentRecord}: optionally an Async Payload Record.
681
+ - {path}: a list of field names and indices from root to the location of the
682
+ corresponding ` @defer ` or ` @stream ` directive.
683
+ - {iterator}: The underlying iterator if created from a ` @stream ` directive.
693
684
- {errors}: a list of field errors encountered during execution.
694
685
- {dataExecution}: A result that can notify when the corresponding execution has
695
686
completed.
696
- - {path}: a list of field names and indices from root to the location of the
697
- corresponding ` @defer ` or ` @stream ` directive.
698
-
699
- #### Deferred Fragment Record
700
-
701
- Let {deferredFragmentRecord} be an inline fragment or fragment spread with
702
- ` @defer ` provided.
703
-
704
- Deferred Fragment Record is a structure containing all the entries of Async
705
- Payload Record, and additionally:
706
687
707
- - {objectType}: of the {deferredFragmentRecord}.
708
- - {objectValue}: of the {deferredFragmentRecord}.
709
- - {fragmentSelectionSet}: the top level selection set of
710
- {deferredFragmentRecord}.
688
+ #### Execute Deferred Fragment
711
689
712
- CreateDeferredFragmentRecord (label, objectType, objectValue,
713
- fragmentSelectionSet, path , parentRecord):
690
+ ExecuteDeferredFragment (label, objectType, objectValue, fragmentSelectionSet ,
691
+ path, variableValues , parentRecord, subsequentPayloads ):
714
692
715
- - Construct a deferred fragment record based on the parameters passed in.
716
- - Initialize {errors} to an empty list.
717
-
718
- ResolveDeferredFragmentRecord(deferredFragmentRecord, variableValues,
719
- subsequentPayloads):
720
-
721
- - Let {label}, {objectType}, {objectValue}, {fragmentSelectionSet}, {path},
722
- {parentRecord} be the corresponding fields in the deferred fragment record
723
- structure.
693
+ - Let {deferRecord} be an async payload record created from {label} and {path}.
694
+ - Initialize {errors} on {deferRecord} to an empty list.
724
695
- Let {dataExecution} be the asynchronous future value of:
725
696
- Let {payload} be the result of {ExecuteSelectionSet(fragmentSelectionSet,
726
697
objectType, objectValue, variableValues, path, subsequentPayloads,
727
- deferredFragmentRecord )}.
698
+ deferRecord )}.
728
699
- If {parentRecord} is defined:
729
700
- Wait for the result of {dataExecution} on {parentRecord}.
701
+ - Add an entry to {payload} named ` label ` with the value {label}.
702
+ - Add an entry to {payload} named ` path ` with the value {path}.
730
703
- Return {payload}.
731
704
- Set {dataExecution} on {deferredFragmentRecord}.
732
- - Let {payload} be the result of waiting for {dataExecution}.
733
- - Add an entry to {payload} named ` label ` with the value {label}.
734
- - Add an entry to {payload} named ` path ` with the value {path}.
735
- - Return {payload}.
705
+ - Append {deferRecord} to {subsequentPayloads}.
736
706
737
707
## Executing Fields
738
708
@@ -876,28 +846,14 @@ field, value completion iterates over the iterator until the number of items
876
846
yield by the iterator satisfies ` initialCount ` specified on the ` @stream `
877
847
directive.
878
848
879
- #### Stream Record
880
-
881
- Let {streamField} be a list field with a ` @stream ` directive provided.
882
-
883
- A Stream Record is a structure containing all the entries of Async Payload
884
- Record, and additionally:
885
-
886
- - {iterator}: created by {ResolveFieldGenerator}.
887
- - {index}: indicating the position of the item in the complete list.
888
- - {fields}: the group of fields grouped by CollectFields() for {streamField}.
889
- - {innerType}: inner type of {streamField}'s type.
890
-
891
- CreateStreamRecord(label, iterator, index, fields, innerType, path,
892
- parentRecord):
893
-
894
- - Construct a stream record based on the parameters passed in.
895
- - Initialize {errors} to an empty list.
849
+ #### Execute Stream Field
896
850
897
- ResolveStreamRecord(streamRecord, variableValues, subsequentPayloads):
851
+ ExecuteStreamRecord(label, iterator, index, fields, innerType, path
852
+ streamRecord, variableValues, subsequentPayloads):
898
853
899
- - Let {label}, {parentRecord}, {iterator}, {index}, {path}, {fields},
900
- {innerType} be the correspondent fields on the Stream Record structure.
854
+ - Let {streamRecord} be an async payload record created from {label}, {path},
855
+ and {iterator}.
856
+ - Initialize {errors} on {streamRecord} to an empty list.
901
857
- Let {indexPath} be {path} with {index} appended.
902
858
- Let {dataExecution} be the asynchronous future value of:
903
859
- Wait for the next item from {iterator}.
@@ -907,17 +863,15 @@ ResolveStreamRecord(streamRecord, variableValues, subsequentPayloads):
907
863
- Let {payload} be the result of calling {CompleteValue(innerType, fields,
908
864
item, variableValues, indexPath, subsequentPayloads, parentRecord)}.
909
865
- Increment {index}.
910
- - Let {nextStreamRecord} be the result of calling {CreateStreamRecord(label,
911
- iterator, index, fields, innerType, path, streamRecord)}.
912
- - Append {nextStreamRecord} to {subsequentPayloads}.
866
+ - Call {ExecuteStreamRecord(label, iterator, index, fields, innerType, path,
867
+ streamRecord, variableValues, subsequentPayloads)}.
913
868
- If {parentRecord} is defined:
914
869
- Wait for the result of {dataExecution} on {parentRecord}.
870
+ - Add an entry to {payload} named ` label ` with the value {label}.
871
+ - Add an entry to {payload} named ` path ` with the value {indexPath}.
915
872
- Return {payload}.
916
873
- Set {dataExecution} on {streamRecord}.
917
- - Let {payload} be the result of waiting for {dataExecution}.
918
- - Add an entry to {payload} named ` label ` with the value {label}.
919
- - Add an entry to {payload} named ` path ` with the value {indexPath}.
920
- - Return {payload}.
874
+ - Append {streamRecord} to {subsequentPayloads}.
921
875
922
876
CompleteValue(fieldType, fields, result, variableValues, path,
923
877
subsequentPayloads, asyncRecord):
@@ -955,9 +909,8 @@ subsequentPayloads, asyncRecord):
955
909
- Increment {index}.
956
910
- If {streamDirective} was provided and {index} is greater than or equal
957
911
to {initialCount}:
958
- - Let {streamRecord} be the result of calling {CreateStreamRecord(label,
959
- result, index, fields, innerType, path, asyncRecord)}.
960
- - Append {streamRecord} to {subsequentPayloads}.
912
+ - Call {ExecuteStreamRecord(label, result, index, fields, innerType,
913
+ path, asyncRecord, subsequentPayloads)}.
961
914
- Let {result} be {initialItems}.
962
915
- Exit while loop.
963
916
- Return {initialItems}.
0 commit comments