@@ -320,31 +320,34 @@ Executing the root selection set works similarly for queries (parallel),
320
320
mutations (serial), and subscriptions (where it is executed for each event in
321
321
the underlying Source Stream).
322
322
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
+
323
326
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
324
327
serial):
325
328
326
329
- 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,
328
333
objectType, initialValue, variableValues)} _ serially_ if {serial} is {true},
329
334
_ normally_ (allowing parallelization) otherwise.
330
335
- Let {errors} be the list of all _ field error_ raised while executing the
331
336
selection set.
332
337
- Return an unordered map containing {data} and {errors}.
333
338
334
- ## Executing Selection Sets
339
+ ## Executing a Grouped Field Set
335
340
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.
339
344
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.
343
347
344
- ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
348
+ ExecuteGroupedFieldSet(groupedFieldSet, objectType, objectValue,
349
+ variableValues):
345
350
346
- - Let {groupedFieldSet} be the result of {CollectFields(objectType,
347
- selectionSet, variableValues)}.
348
351
- Initialize {resultMap} to an empty ordered map.
349
352
- For each {groupedFieldSet} as {responseKey} and {fields}:
350
353
- 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.
362
365
363
366
** Errors and Non-Null Fields**
364
367
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,
367
370
either resolving to {null} if allowed or further propagated to a parent field.
368
371
369
372
If this occurs, any sibling fields which have not yet executed or have not yet
@@ -701,8 +704,9 @@ CompleteValue(fieldType, fields, result, variableValues):
701
704
- Let {objectType} be {fieldType}.
702
705
- Otherwise if {fieldType} is an Interface or Union type.
703
706
- 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,
706
710
objectType, result, variableValues)} _ normally_ (allowing for
707
711
parallelization).
708
712
@@ -749,9 +753,9 @@ ResolveAbstractType(abstractType, objectValue):
749
753
750
754
** Merging Selection Sets**
751
755
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.
755
759
756
760
An example operation illustrating parallel fields with the same name with
757
761
sub-selections.
@@ -770,14 +774,19 @@ sub-selections.
770
774
After resolving the value for ` me ` , the selection sets are merged together so
771
775
` firstName ` and ` lastName ` can be resolved for one value.
772
776
773
- MergeSelectionSets( fields):
777
+ CollectSubfields(objectType, fields, variableValues ):
774
778
775
- - Let {selectionSet } be an empty list .
779
+ - Let {groupedFieldSet } be an empty map .
776
780
- For each {field} in {fields}:
777
781
- Let {fieldSelectionSet} be the selection set of {field}.
778
782
- 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}.
781
790
782
791
### Handling Field Errors
783
792
0 commit comments