@@ -496,9 +496,12 @@ BatchIncrementalResults(incrementalResults):
496496
497497## Executing an Execution Plan
498498
499- To execute a execution plan, the object value being evaluated and the object
500- type need to be known, as well as whether the non-deferred grouped field set
501- must be executed serially, or may be executed in parallel.
499+ Executing an execution plan consists of two tasks that may be performed in
500+ parallel. The first task is simply the execution of the non-deferred grouped
501+ field set. The second task is to use the partitioned grouped field sets within
502+ the execution plan to generate Execution Groups, i.e. Incremental Data Records,
503+ where each Incremental Data Records represents the deferred execution of one of
504+ the partitioned grouped field sets.
502505
503506ExecuteExecutionPlan(newDeferUsages, executionPlan, objectType, objectValue,
504507variableValues, serial, path, deferUsageSet, deferMap):
@@ -520,6 +523,15 @@ variableValues, serial, path, deferUsageSet, deferMap):
520523 {incrementalDataRecords}.
521524- Return {data} and {incrementalDataRecords}.
522525
526+ Because ` @defer ` directives may be nested within list types, a map is required
527+ to associate a Defer Usage record as recorded within Field Details Records and
528+ an actual Deferred Fragment so that any additional Execution Groups may be
529+ associated with the correct Deferred Fragment. The {GetNewDeferMap()} algorithm
530+ creates that map. Given a list of new Defer Usages, the actual path at which the
531+ fields they defer are spread, and an initial map, it returns a new map
532+ containing all entries in the provided defer map, as well as new entries for
533+ each new Defer Usage.
534+
523535GetNewDeferMap(newDeferUsages, path, deferMap):
524536
525537- If {newDeferUsages} is empty, return {deferMap}:
@@ -533,6 +545,11 @@ GetNewDeferMap(newDeferUsages, path, deferMap):
533545 - Set the entry for {deferUsage} in {newDeferMap} to {newDeferredFragment}.
534546- Return {newDeferMap}.
535547
548+ The {CollectExecutionGroups()} algorithm is responsible for creating the
549+ Execution Groups, i.e. Incremental Data Records, for each partitioned grouped
550+ field set. It uses the map created by {GetNewDeferMap()} algorithm to associate
551+ each Execution Group with the correct Deferred Fragment.
552+
536553CollectExecutionGroups(objectType, objectValue, variableValues,
537554newGroupedFieldSets, path, deferMap):
538555
@@ -554,14 +571,18 @@ newGroupedFieldSets, path, deferMap):
554571Note: {incrementalDataRecord} can be safely initiated without blocking
555572higher-priority data once any of {deferredFragments} are released as pending.
556573
574+ The {ExecuteExecutionGroup()} algorithm is responsible for actually executing
575+ the deferred grouped field set and collecting the result and any raised errors.
576+
557577ExecuteExecutionGroup(groupedFieldSet, objectType, objectValue, variableValues,
558578path, deferUsageSet, deferMap):
559579
560580- Let {data} and {incrementalDataRecords} be the result of running
561581 {ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
562582 variableValues, path, deferUsageSet, deferMap)} _ normally_ (allowing
563583 parallelization).
564- - Let {errors} be the list of all _ field error_ raised while completing {data}.
584+ - Let {errors} be the list of all _ field error_ raised while executing
585+ {ExecuteGroupedFieldSet()}.
565586- Return an unordered map containing {data}, {errors}, and
566587 {incrementalDataRecords}.
567588
@@ -884,6 +905,15 @@ choose to memoize their implementations of {CollectFields}.
884905
885906### Execution Plan Generation
886907
908+ A grouped field set may contain fields that have been deferred by the use of the
909+ ` @defer ` directive on their enclosing fragments. Given a grouped field set,
910+ {BuildExecutionPlan()} generates an execution plan by partitioning the grouped
911+ field as specified by the operation's use of ` @defer ` and the requirements of
912+ the incremental response format. An execution plan consists of a single new
913+ grouped field containing the fields that do not require deferral, and a map of
914+ new grouped field set containing where the keys represent the set of Defer
915+ Usages containing those fields.
916+
887917BuildExecutionPlan(originalGroupedFieldSet, parentDeferUsages):
888918
889919- If {parentDeferUsages} is not provided, initialize it to the empty set.
0 commit comments