@@ -321,31 +321,34 @@ Executing the root selection set works similarly for queries (parallel),
321321mutations (serial), and subscriptions (where it is executed for each event in
322322the underlying Source Stream).
323323
324+ First, the selection set is turned into a grouped field set; then, we execute
325+ this grouped field set and return the resulting {data} and {errors}.
326+
324327ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
325328serial):
326329
327330- If {serial} is not provided, initialize it to {false}.
328- - Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
331+ - Let {groupedFieldSet} be the result of {CollectFields(objectType,
332+ selectionSet, variableValues)}.
333+ - Let {data} be the result of running {ExecuteGroupedFieldSet(groupedFieldSet,
329334 objectType, initialValue, variableValues)} _ serially_ if {serial} is {true},
330335 _ normally_ (allowing parallelization) otherwise.
331336- Let {errors} be the list of all _ field error_ raised while executing the
332337 selection set.
333338- Return an unordered map containing {data} and {errors}.
334339
335- ## Executing Selection Sets
340+ ## Executing a Grouped Field Set
336341
337- To execute a selection set, the object value being evaluated and the object type
338- need to be known, as well as whether it must be executed serially, or may be
339- executed in parallel.
342+ To execute a grouped field set, the object value being evaluated and the object
343+ type need to be known, as well as whether it must be executed serially, or may
344+ be executed in parallel.
340345
341- First, the selection set is turned into a grouped field set; then, each
342- represented field in the grouped field set produces an entry into a response
343- map.
346+ Each represented field in the grouped field set produces an entry into a
347+ response map.
344348
345- ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
349+ ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
350+ variableValues):
346351
347- - Let {groupedFieldSet} be the result of {CollectFields(objectType,
348- selectionSet, variableValues)}.
349352- Initialize {resultMap} to an empty ordered map.
350353- For each {groupedFieldSet} as {responseKey} and {fields}:
351354 - Let {fieldName} be the name of the first entry in {fields}. Note: This value
@@ -363,8 +366,8 @@ is explained in greater detail in the Field Collection section below.
363366
364367** Errors and Non-Null Fields**
365368
366- If during {ExecuteSelectionSet ()} a field with a non-null {fieldType} raises a
367- _ field error_ then that error must propagate to this entire selection set,
369+ If during {ExecuteGroupedFieldSet ()} a field with a non-null {fieldType} raises
370+ a _ field error_ then that error must propagate to this entire selection set,
368371either resolving to {null} if allowed or further propagated to a parent field.
369372
370373If this occurs, any sibling fields which have not yet executed or have not yet
@@ -702,8 +705,9 @@ CompleteValue(fieldType, fields, result, variableValues):
702705 - Let {objectType} be {fieldType}.
703706 - Otherwise if {fieldType} is an Interface or Union type.
704707 - Let {objectType} be {ResolveAbstractType(fieldType, result)}.
705- - Let {subSelectionSet} be the result of calling {MergeSelectionSets(fields)}.
706- - Return the result of evaluating {ExecuteSelectionSet(subSelectionSet,
708+ - Let {groupedFieldSet} be the result of calling {CollectSubfields(objectType,
709+ fields, variableValues)}.
710+ - Return the result of evaluating {ExecuteGroupedFieldSet(groupedFieldSet,
707711 objectType, result, variableValues)} _ normally_ (allowing for
708712 parallelization).
709713
@@ -750,9 +754,9 @@ ResolveAbstractType(abstractType, objectValue):
750754
751755** Merging Selection Sets**
752756
753- When more than one field of the same name is executed in parallel, their
754- selection sets are merged together when completing the value in order to
755- continue execution of the sub-selection sets.
757+ When more than one field of the same name is executed in parallel, during value
758+ completion their selection sets are collected together to produce a single
759+ grouped field set in order to continue execution of the sub-selection sets.
756760
757761An example operation illustrating parallel fields with the same name with
758762sub-selections.
@@ -771,14 +775,19 @@ sub-selections.
771775After resolving the value for ` me ` , the selection sets are merged together so
772776` firstName ` and ` lastName ` can be resolved for one value.
773777
774- MergeSelectionSets( fields):
778+ CollectSubfields(objectType, fields, variableValues ):
775779
776- - Let {selectionSet } be an empty list .
780+ - Let {groupedFieldSet } be an empty map .
777781- For each {field} in {fields}:
778782 - Let {fieldSelectionSet} be the selection set of {field}.
779783 - If {fieldSelectionSet} is null or empty, continue to the next field.
780- - Append all selections in {fieldSelectionSet} to {selectionSet}.
781- - Return {selectionSet}.
784+ - Let {subGroupedFieldSet} be the result of {CollectFields(objectType,
785+ fieldSelectionSet, variableValues)}.
786+ - For each {subGroupedFieldSet} as {responseKey} and {subfields}:
787+ - Let {groupForResponseKey} be the list in {groupedFieldSet} for
788+ {responseKey}; if no such list exists, create it as an empty list.
789+ - Append all fields in {subfields} to {groupForResponseKey}.
790+ - Return {groupedFieldSet}.
782791
783792### Handling Field Errors
784793
0 commit comments