Skip to content

Commit 6cc43d1

Browse files
committed
add initial versions of explanations for the algorithms in the "Executing an Execution Plan" section
1 parent 7c0088e commit 6cc43d1

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

spec/Section 6 -- Execution.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,12 @@ BatchIncrementalResults(incrementalResults):
499499

500500
## Executing an Execution Plan
501501

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.
505508

506509
ExecuteExecutionPlan(newDeferUsages, executionPlan, objectType, objectValue,
507510
variableValues, serial, path, deferUsageSet, deferMap):
@@ -523,6 +526,15 @@ variableValues, serial, path, deferUsageSet, deferMap):
523526
{incrementalDataRecords}.
524527
- Return {data} and {incrementalDataRecords}.
525528

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+
526538
GetNewDeferMap(newDeferUsages, path, deferMap):
527539

528540
- If {newDeferUsages} is empty, return {deferMap}:
@@ -536,6 +548,11 @@ GetNewDeferMap(newDeferUsages, path, deferMap):
536548
- Set the entry for {deferUsage} in {newDeferMap} to {newDeferredFragment}.
537549
- Return {newDeferMap}.
538550

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+
539556
CollectExecutionGroups(objectType, objectValue, variableValues,
540557
newGroupedFieldSets, path, deferMap):
541558

@@ -557,14 +574,18 @@ newGroupedFieldSets, path, deferMap):
557574
Note: {incrementalDataRecord} can be safely initiated without blocking
558575
higher-priority data once any of {deferredFragments} are released as pending.
559576

577+
The {ExecuteExecutionGroup()} algorithm is responsible for actually executing
578+
the deferred grouped field set and collecting the result and any raised errors.
579+
560580
ExecuteExecutionGroup(groupedFieldSet, objectType, objectValue, variableValues,
561581
path, deferUsageSet, deferMap):
562582

563583
- Let {data} and {incrementalDataRecords} be the result of running
564584
{ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
565585
variableValues, path, deferUsageSet, deferMap)} _normally_ (allowing
566586
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()}.
568589
- Return an unordered map containing {data}, {errors}, and
569590
{incrementalDataRecords}.
570591

@@ -887,6 +908,15 @@ choose to memoize their implementations of {CollectFields}.
887908

888909
### Execution Plan Generation
889910

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+
890920
BuildExecutionPlan(originalGroupedFieldSet, parentDeferUsages):
891921

892922
- If {parentDeferUsages} is not provided, initialize it to the empty set.

0 commit comments

Comments
 (0)