@@ -499,9 +499,12 @@ BatchIncrementalResults(incrementalResults):
499
499
500
500
## Executing an Execution Plan
501
501
502
- To execute a execution plan, the object value being evaluated and the object
503
- type need to be known, as well as whether the non-deferred grouped field set
504
- must be executed serially, or may be executed in parallel.
502
+ Executing an execution plan consists of two tasks that may be performed in
503
+ parallel. The first task is simply the execution of the non-deferred grouped
504
+ field set. The second task is to use the partitioned grouped field sets within
505
+ the execution plan to generate Execution Groups, i.e. Incremental Data Records,
506
+ where each Incremental Data Records represents the deferred execution of one of
507
+ the partitioned grouped field sets.
505
508
506
509
ExecuteExecutionPlan(newDeferUsages, executionPlan, objectType, objectValue,
507
510
variableValues, serial, path, deferUsageSet, deferMap):
@@ -523,6 +526,15 @@ variableValues, serial, path, deferUsageSet, deferMap):
523
526
{incrementalDataRecords}.
524
527
- Return {data} and {incrementalDataRecords}.
525
528
529
+ Because ` @defer ` directives may be nested within list types, a map is required
530
+ to associate a Defer Usage record as recorded within Field Details Records and
531
+ an actual Deferred Fragment so that any additional Execution Groups may be
532
+ associated with the correct Deferred Fragment. The {GetNewDeferMap()} algorithm
533
+ creates that map. Given a list of new Defer Usages, the actual path at which the
534
+ fields they defer are spread, and an initial map, it returns a new map
535
+ containing all entries in the provided defer map, as well as new entries for
536
+ each new Defer Usage.
537
+
526
538
GetNewDeferMap(newDeferUsages, path, deferMap):
527
539
528
540
- If {newDeferUsages} is empty, return {deferMap}:
@@ -536,6 +548,11 @@ GetNewDeferMap(newDeferUsages, path, deferMap):
536
548
- Set the entry for {deferUsage} in {newDeferMap} to {newDeferredFragment}.
537
549
- Return {newDeferMap}.
538
550
551
+ The {CollectExecutionGroups()} algorithm is responsible for creating the
552
+ Execution Groups, i.e. Incremental Data Records, for each partitioned grouped
553
+ field set. It uses the map created by {GetNewDeferMap()} algorithm to associate
554
+ each Execution Group with the correct Deferred Fragment.
555
+
539
556
CollectExecutionGroups(objectType, objectValue, variableValues,
540
557
newGroupedFieldSets, path, deferMap):
541
558
@@ -557,14 +574,18 @@ newGroupedFieldSets, path, deferMap):
557
574
Note: {incrementalDataRecord} can be safely initiated without blocking
558
575
higher-priority data once any of {deferredFragments} are released as pending.
559
576
577
+ The {ExecuteExecutionGroup()} algorithm is responsible for actually executing
578
+ the deferred grouped field set and collecting the result and any raised errors.
579
+
560
580
ExecuteExecutionGroup(groupedFieldSet, objectType, objectValue, variableValues,
561
581
path, deferUsageSet, deferMap):
562
582
563
583
- Let {data} and {incrementalDataRecords} be the result of running
564
584
{ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
565
585
variableValues, path, deferUsageSet, deferMap)} _ normally_ (allowing
566
586
parallelization).
567
- - Let {errors} be the list of all _ field error_ raised while completing {data}.
587
+ - Let {errors} be the list of all _ field error_ raised while executing
588
+ {ExecuteGroupedFieldSet()}.
568
589
- Return an unordered map containing {data}, {errors}, and
569
590
{incrementalDataRecords}.
570
591
@@ -887,6 +908,15 @@ choose to memoize their implementations of {CollectFields}.
887
908
888
909
### Execution Plan Generation
889
910
911
+ A grouped field set may contain fields that have been deferred by the use of the
912
+ ` @defer ` directive on their enclosing fragments. Given a grouped field set,
913
+ {BuildExecutionPlan()} generates an execution plan by partitioning the grouped
914
+ field as specified by the operation's use of ` @defer ` and the requirements of
915
+ the incremental response format. An execution plan consists of a single new
916
+ grouped field containing the fields that do not require deferral, and a map of
917
+ new grouped field set containing where the keys represent the set of Defer
918
+ Usages containing those fields.
919
+
890
920
BuildExecutionPlan(originalGroupedFieldSet, parentDeferUsages):
891
921
892
922
- If {parentDeferUsages} is not provided, initialize it to the empty set.
0 commit comments