Skip to content

Commit f3b6a3f

Browse files
committed
bring BuildFieldPlan in line with implementation
1 parent 76b7385 commit f3b6a3f

File tree

1 file changed

+34
-21
lines changed

1 file changed

+34
-21
lines changed

spec/Section 6 -- Execution.md

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -630,27 +630,41 @@ directives may be applied in either order since they apply commutatively.
630630
BuildFieldPlan(originalGroupedFieldSet, parentDeferUsages):
631631

632632
- If {parentDeferUsages} is not provided, initialize it to the empty set.
633-
- Initialize {fieldPlan} to an empty ordered map.
633+
- Initialize {groupedFieldSet} to an empty ordered map.
634+
- Initialize {newGroupedFieldSets} to an empty unordered map.
635+
- Let {fieldPlan} be an unordered map containing {groupedFieldSet} and
636+
{newGroupedFieldSets}.
634637
- For each {responseKey} and {groupForResponseKey} of {groupedFieldSet}:
635-
- Let {deferUsageSet} be the result of
636-
{GetDeferUsageSet(groupForResponseKey)}.
637-
- Let {groupedFieldSet} be the entry in {fieldPlan} for any equivalent set to
638-
{deferUsageSet}; if no such map exists, create it as an empty ordered map.
639-
- Set the entry for {responseKey} in {groupedFieldSet} to
640-
{groupForResponseKey}.
638+
- Let {filteredDeferUsageSet} be the result of
639+
{GetFilteredDeferUsageSet(groupForResponseKey)}.
640+
- If {filteredDeferUsageSet} is the equivalent set to {parentDeferUsages}:
641+
- Set the entry for {responseKey} in {groupedFieldSet} to
642+
{groupForResponseKey}.
643+
- Otherwise:
644+
- Let {newGroupedFieldSet} be the entry in {newGroupedFieldSets} for any
645+
equivalent set to {deferUsageSet}; if no such map exists, create it as an
646+
empty ordered map.
647+
- Set the entry for {responseKey} in {newGroupedFieldSet} to
648+
{groupForResponseKey}.
641649
- Return {fieldPlan}.
642650

643-
GetDeferUsageSet(fieldDetailsList):
644-
645-
- Let {deferUsageSet} be the set containing the {deferUsage} entry from each
646-
item in {fieldDetailsList}.
647-
- For each {deferUsage} of {deferUsageSet}:
648-
- Let {ancestors} be the set of {deferUsage} entries that are ancestors of
649-
{deferUsage}, collected by recursively following the {parent} entry on
650-
{deferUsage}.
651-
- If any of {ancestors} is contained by {deferUsageSet}, remove {deferUsage}
652-
from {deferUsageSet}.
653-
- Return {deferUsageSet}.
651+
GetFilteredDeferUsageSet(fieldGroup):
652+
653+
- Initialize {filteredDeferUsageSet} to the empty set.
654+
- For each {fieldDetails} of {fieldGroup}:
655+
- Let {deferUsage} be the corresponding entry on {fieldDetails}.
656+
- If {deferUsage} is not defined:
657+
- Remove all entries from {filteredDeferUsageSet}.
658+
- Return {filteredDeferUsageSet}.
659+
- Add {deferUsage} to {filteredDeferUsageSet}.
660+
- For each {deferUsage} in {filteredDeferUsageSet}:
661+
- Let {parentDeferUsage} be the corresponding entry on {deferUsage}.
662+
- While {parentDeferUsage} is defined:
663+
- If {parentDeferUsage} is contained by {filteredDeferUsageSet}:
664+
- Remove {deferUsage} from {filteredDeferUsageSet}.
665+
- Continue to the next {deferUsage} in {filteredDeferUsageSet}.
666+
- Reset {parentDeferUsage} to the corresponding entry on {parentDeferUsage}.
667+
- Return {filteredDeferUsageSet}.
654668

655669
## Executing a Field Plan
656670

@@ -664,9 +678,8 @@ variableValues, serial, path, deferUsageSet, deferMap):
664678
- If {path} is not provided, initialize it to an empty list.
665679
- Let {newDeferMap} be the result of {GetNewDeferMap(newDeferUsages, path,
666680
deferMap)}.
667-
- Let {groupedFieldSet} be the entry in {fieldPlan} for the set equivalent to
668-
{deferUsageSet}.
669-
- Let {newGroupedFieldSets} be the remaining portion of {fieldPlan}.
681+
- Let {groupedFieldSet} and {newGroupedFieldSets} be the corresponding entries
682+
on {fieldPlan}.
670683
- Allowing for parallelization, perform the following steps:
671684
- Let {data} and {nestedIncrementalDataRecords} be the result of running
672685
{ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,

0 commit comments

Comments
 (0)