@@ -1076,6 +1076,44 @@ BuildGroupedFieldSets(fieldsByTarget, targetsByKey, parentTargets)
10761076 - Initialize {details} to an empty unordered map.
10771077 - Set the entry for {groupedFieldSet} in {details} to {newGroupedFieldSet}.
10781078 - Set the corresponding entry in {details} to {shouldInitiateDefer}.
1079+ - Set the entry for {targets} in {groupDetailsMap} to {details}.
1080+ - Return {groupedFieldSet} and {groupDetailsMap}.
1081+
1082+ Note: entries are always added to Grouped Field Set records in the order in
1083+ which they appear for the first target. Field order for deferred grouped field
1084+ sets never alters the field order for the parent.
1085+
1086+ GetTargetSetDetails(targetsByKey, parentTargets):
1087+
1088+ - Initialize {keysWithParentTargets} to the empty set.
1089+ - Initialize {targetSetDetailsMap} to an empty unordered map.
1090+ - For each {responseKey} and {targets} in {targetsByKey}:
1091+ - If {IsSameSet(targets, parentTargets)} is {true}:
1092+ - Append {responseKey} to {keysWithParentTargets}.
1093+ - Continue to the next entry in {targetsByKey}.
1094+ - For each {key} in {targetSetDetailsMap}:
1095+ - If {IsSameSet(targets, key)} is {true}, let {targetSetDetails} be the map
1096+ in {targetSetDetailsMap} for {targets}.
1097+ - If {targetSetDetails} is defined:
1098+ - Let {keys} be the corresponding entry on {targetSetDetails}.
1099+ - Add {responseKey} to {keys}.
1100+ - Otherwise:
1101+ - Initialize {keys} to the empty set.
1102+ - Add {responseKey} to {keys}.
1103+ - Let {shouldInitiateDefer} be {false}.
1104+ - For each {target} in {targets}:
1105+ - Let {remainingFieldsForTarget} be the entry in {remainingFieldsByTarget}
1106+ for {target}.
1107+ - Let {nodes} be the list in {remainingFieldsByTarget} for {responseKey}.
1108+ - Remove the entry for {responseKey} from {remainingFieldsByTarget}.
1109+ - For each {node} of {nodes}:
1110+ - Let {fieldDetails} be a new Field Details record created from {node}
1111+ and {target}.
1112+ - Append {fieldDetails} to the {fields} entry on {fieldGroup}.
1113+ - Let {shouldInitiateDefer} be the corresponding entry on {targetSetDetails}.
1114+ - Initialize {details} to an empty unordered map.
1115+ - Set the entry for {groupedFieldSet} in {details} to {newGroupedFieldSet}.
1116+ - Set the corresponding entry in {details} to {shouldInitiateDefer}.
10791117 - Set the entry for {maskingTargets} in {groupDetailsMap} to {details}.
10801118- Return {groupedFieldSet} and {groupDetailsMap}.
10811119
@@ -1116,7 +1154,7 @@ GetTargetSetDetails(targetsByKey, parentTargets):
11161154 - Set {shouldInitiateDefer} equal to {true}.
11171155 - Create {newTargetSetDetails} as an map containing {keys} and
11181156 {shouldInitiateDefer}.
1119- - Set the entry in {targetSetDetailsMap} for {maskingTargets } to
1157+ - Set the entry in {targetSetDetailsMap} for {targets } to
11201158 {newTargetSetDetails}.
11211159- Return {keysWithParentTargets} and {targetSetDetailsMap}.
11221160
@@ -1129,6 +1167,15 @@ IsSameSet(setA, setB):
11291167 - Return {false}.
11301168- Return {true}.
11311169
1170+ GetOrderedResponseKeys(targets, fieldsByTarget):
1171+
1172+ - Let {firstTarget} be the first entry in {targets}.
1173+ - Assert that {firstTarget} is defined.
1174+ - Let {firstFields} be the entry for {firstTarget} in {fieldsByTarget}.
1175+ - Assert that {firstFields} is defined.
1176+ - Let {responseKeys} be the keys of {firstFields}.
1177+ - Return {responseKeys}.
1178+
11321179## Executing Deferred Grouped Field Sets
11331180
11341181ExecuteDeferredGroupedFieldSets(objectType, objectValue, variableValues, path,
0 commit comments