@@ -320,31 +320,34 @@ Executing the root selection set works similarly for queries (parallel),
320320mutations (serial), and subscriptions (where it is executed for each event in
321321the underlying Source Stream).
322322
323+ First, the selection set is turned into a grouped field set; then, we execute
324+ this grouped field set and return the resulting {data} and {errors}.
325+
323326ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
324327serial):
325328
326329- If {serial} is not provided, initialize it to {false}.
327- - Let {data} be the result of running {ExecuteSelectionSet(selectionSet,
330+ - Let {groupedFieldSet} be the result of {CollectFields(objectType,
331+ selectionSet, variableValues)}.
332+ - Let {data} be the result of running {ExecuteGroupedFieldSet(groupedFieldSet,
328333 objectType, initialValue, variableValues)} _ serially_ if {serial} is {true},
329334 _ normally_ (allowing parallelization) otherwise.
330335- Let {errors} be the list of all _ field error_ raised while executing the
331336 selection set.
332337- Return an unordered map containing {data} and {errors}.
333338
334- ## Executing Selection Sets
339+ ## Executing a Grouped Field Set
335340
336- To execute a selection set, the object value being evaluated and the object type
337- need to be known, as well as whether it must be executed serially, or may be
338- executed in parallel.
341+ To execute a grouped field set, the object value being evaluated and the object
342+ type need to be known, as well as whether it must be executed serially, or may
343+ be executed in parallel.
339344
340- First, the selection set is turned into a grouped field set; then, each
341- represented field in the grouped field set produces an entry into a response
342- map.
345+ Each represented field in the grouped field set produces an entry into a
346+ response map.
343347
344- ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
348+ ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
349+ variableValues):
345350
346- - Let {groupedFieldSet} be the result of {CollectFields(objectType,
347- selectionSet, variableValues)}.
348351- Initialize {resultMap} to an empty ordered map.
349352- For each {groupedFieldSet} as {responseKey} and {fields}:
350353 - Let {fieldName} be the name of the first entry in {fields}. Note: This value
@@ -362,8 +365,8 @@ is explained in greater detail in the Field Collection section below.
362365
363366** Errors and Non-Null Fields**
364367
365- If during {ExecuteSelectionSet ()} a field with a non-null {fieldType} raises a
366- _ field error_ then that error must propagate to this entire selection set,
368+ If during {ExecuteGroupedFieldSet ()} a field with a non-null {fieldType} raises
369+ a _ field error_ then that error must propagate to this entire selection set,
367370either resolving to {null} if allowed or further propagated to a parent field.
368371
369372If this occurs, any sibling fields which have not yet executed or have not yet
@@ -701,8 +704,9 @@ CompleteValue(fieldType, fields, result, variableValues):
701704 - Let {objectType} be {fieldType}.
702705 - Otherwise if {fieldType} is an Interface or Union type.
703706 - Let {objectType} be {ResolveAbstractType(fieldType, result)}.
704- - Let {subSelectionSet} be the result of calling {MergeSelectionSets(fields)}.
705- - Return the result of evaluating {ExecuteSelectionSet(subSelectionSet,
707+ - Let {groupedFieldSet} be the result of calling {CollectSubfields(objectType,
708+ fields, variableValues)}.
709+ - Return the result of evaluating {ExecuteGroupedFieldSet(groupedFieldSet,
706710 objectType, result, variableValues)} _ normally_ (allowing for
707711 parallelization).
708712
@@ -749,9 +753,9 @@ ResolveAbstractType(abstractType, objectValue):
749753
750754** Merging Selection Sets**
751755
752- When more than one field of the same name is executed in parallel, their
753- selection sets are merged together when completing the value in order to
754- continue execution of the sub-selection sets.
756+ When more than one field of the same name is executed in parallel, during value
757+ completion their selection sets are collected together to produce a single
758+ grouped field set in order to continue execution of the sub-selection sets.
755759
756760An example operation illustrating parallel fields with the same name with
757761sub-selections.
@@ -770,14 +774,19 @@ sub-selections.
770774After resolving the value for ` me ` , the selection sets are merged together so
771775` firstName ` and ` lastName ` can be resolved for one value.
772776
773- MergeSelectionSets( fields):
777+ CollectSubfields(objectType, fields, variableValues ):
774778
775- - Let {selectionSet } be an empty list .
779+ - Let {groupedFieldSet } be an empty map .
776780- For each {field} in {fields}:
777781 - Let {fieldSelectionSet} be the selection set of {field}.
778782 - If {fieldSelectionSet} is null or empty, continue to the next field.
779- - Append all selections in {fieldSelectionSet} to {selectionSet}.
780- - Return {selectionSet}.
783+ - Let {subGroupedFieldSet} be the result of {CollectFields(objectType,
784+ fieldSelectionSet, variableValues)}.
785+ - For each {subGroupedFieldSet} as {responseKey} and {subfields}:
786+ - Let {groupForResponseKey} be the list in {groupedFieldSet} for
787+ {responseKey}; if no such list exists, create it as an empty list.
788+ - Append all fields in {subfields} to {groupForResponseKey}.
789+ - Return {groupedFieldSet}.
781790
782791### Handling Field Errors
783792
0 commit comments