@@ -496,9 +496,12 @@ BatchIncrementalResults(incrementalResults):
496
496
497
497
## Executing an Execution Plan
498
498
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.
502
505
503
506
ExecuteExecutionPlan(newDeferUsages, executionPlan, objectType, objectValue,
504
507
variableValues, serial, path, deferUsageSet, deferMap):
@@ -520,6 +523,15 @@ variableValues, serial, path, deferUsageSet, deferMap):
520
523
{incrementalDataRecords}.
521
524
- Return {data} and {incrementalDataRecords}.
522
525
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
+
523
535
GetNewDeferMap(newDeferUsages, path, deferMap):
524
536
525
537
- If {newDeferUsages} is empty, return {deferMap}:
@@ -533,6 +545,11 @@ GetNewDeferMap(newDeferUsages, path, deferMap):
533
545
- Set the entry for {deferUsage} in {newDeferMap} to {newDeferredFragment}.
534
546
- Return {newDeferMap}.
535
547
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
+
536
553
CollectExecutionGroups(objectType, objectValue, variableValues,
537
554
newGroupedFieldSets, path, deferMap):
538
555
@@ -554,14 +571,18 @@ newGroupedFieldSets, path, deferMap):
554
571
Note: {incrementalDataRecord} can be safely initiated without blocking
555
572
higher-priority data once any of {deferredFragments} are released as pending.
556
573
574
+ The {ExecuteExecutionGroup()} algorithm is responsible for actually executing
575
+ the deferred grouped field set and collecting the result and any raised errors.
576
+
557
577
ExecuteExecutionGroup(groupedFieldSet, objectType, objectValue, variableValues,
558
578
path, deferUsageSet, deferMap):
559
579
560
580
- Let {data} and {incrementalDataRecords} be the result of running
561
581
{ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
562
582
variableValues, path, deferUsageSet, deferMap)} _ normally_ (allowing
563
583
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()}.
565
586
- Return an unordered map containing {data}, {errors}, and
566
587
{incrementalDataRecords}.
567
588
@@ -884,6 +905,15 @@ choose to memoize their implementations of {CollectFields}.
884
905
885
906
### Execution Plan Generation
886
907
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
+
887
917
BuildExecutionPlan(originalGroupedFieldSet, parentDeferUsages):
888
918
889
919
- If {parentDeferUsages} is not provided, initialize it to the empty set.
0 commit comments