@@ -268,10 +268,11 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
268
268
- Let {subscriptionType} be the root Subscription type in {schema}.
269
269
- Assert: {subscriptionType} is an Object type.
270
270
- Let {selectionSet} be the top level selection set in {subscription}.
271
- - Let {groupedFieldSet } be the result of {CollectFields(subscriptionType,
271
+ - Let {collectedFieldsMap } be the result of {CollectFields(subscriptionType,
272
272
selectionSet, variableValues)}.
273
- - If {groupedFieldSet} does not have exactly one entry, raise a _ request error_ .
274
- - Let {fields} be the value of the first entry in {groupedFieldSet}.
273
+ - If {collectedFieldsMap} does not have exactly one entry, raise a _ request
274
+ error_ .
275
+ - Let {fields} be the value of the first entry in {collectedFieldsMap}.
275
276
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
276
277
is unaffected if an alias is used.
277
278
- Let {field} be the first entry in {fields}.
@@ -368,44 +369,46 @@ Executing the root selection set works similarly for queries (parallel),
368
369
mutations (serial), and subscriptions (where it is executed for each event in
369
370
the underlying Source Stream).
370
371
371
- First, the _ selection set_ is collected into a _ grouped field set _ which is then
372
- executed, returning the resulting {data} and {errors}.
372
+ First, the _ selection set_ is collected into a _ collected fields map _ which is
373
+ then executed, returning the resulting {data} and {errors}.
373
374
374
375
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
375
376
executionMode):
376
377
377
- - Let {groupedFieldSet } be the result of {CollectFields(objectType,
378
+ - Let {collectedFieldsMap } be the result of {CollectFields(objectType,
378
379
selectionSet, variableValues)}.
379
- - Let {data} be the result of running {ExecuteCollectedFields(groupedFieldSet,
380
- objectType, initialValue, variableValues)} _ serially_ if {executionMode} is
381
- {"serial"}, otherwise _ normally_ (allowing parallelization)).
380
+ - Let {data} be the result of running
381
+ {ExecuteCollectedFields(collectedFieldsMap, objectType, initialValue,
382
+ variableValues)} _ serially_ if {executionMode} is {"serial"}, otherwise
383
+ _ normally_ (allowing parallelization)).
382
384
- Let {errors} be the list of all _ execution error_ raised while executing the
383
385
selection set.
384
386
- Return an unordered map containing {data} and {errors}.
385
387
386
388
### Field Collection
387
389
388
- Before execution, each _ selection set_ is converted to a _ grouped field set _ by
389
- calling {CollectFields()}. This ensures all fields with the same response name,
390
- including those in referenced fragments, are executed at the same time.
390
+ Before execution, each _ selection set_ is converted to a _ collected fields map _
391
+ by calling {CollectFields()}. This ensures all fields with the same response
392
+ name, including those in referenced fragments, are executed at the same time.
391
393
392
- :: A _ grouped field set _ is a map where each entry is a _ response name _ and its
393
- associated _ field set_ . A _ grouped field set _ may be produced from a selection
394
- set via {CollectFields()} or from the selection sets of a _ field set _ via
395
- {CollectSubfields()}.
394
+ :: A _ collected fields map _ is an ordered map where each entry is a _ response
395
+ name _ and its associated _ field set_ . A _ collected fields map _ may be produced
396
+ from a selection set via {CollectFields()} or from the selection sets of all
397
+ entries of a _ field set _ via {CollectSubfields()}.
396
398
397
399
:: A _ field set_ is an ordered set of selected fields that share the same
398
400
_ response name_ (the field alias if defined, otherwise the field's name).
399
401
Validation ensures each field in the set has the same name and arguments,
400
402
however each may have different subfields (see:
401
403
[ Field Selection Merging] ( #sec-Field-Selection-Merging ) ).
402
404
403
- Note: The order of field selections in a _ field set_ is significant, hence the
404
- algorithms in this specification model it as an ordered set.
405
+ Note: The order of field selections in both a _ collected fields map_ and a
406
+ _ field set_ are significant, hence the algorithms in this specification model
407
+ them as an ordered map and ordered set.
405
408
406
409
As an example, collecting the fields of this query's selection set would result
407
- in a grouped field set with two entries, ` "a" ` and ` "b" ` , with two instances of
408
- the field ` a ` and one of field ` b ` :
410
+ in a collected fields map with two entries, ` "a" ` and ` "b" ` , with two instances
411
+ of the field ` a ` and one of field ` b ` :
409
412
410
413
``` graphql example
411
414
{
@@ -423,14 +426,14 @@ fragment ExampleFragment on Query {
423
426
}
424
427
```
425
428
426
- The depth-first-search order of the field groups produced by {CollectFields()}
427
- is maintained through execution, ensuring that fields appear in the executed
429
+ The depth-first-search order of the _ field set _ produced by {CollectFields()} is
430
+ maintained through execution, ensuring that fields appear in the executed
428
431
response in a stable and predictable order.
429
432
430
433
CollectFields(objectType, selectionSet, variableValues, visitedFragments):
431
434
432
435
- If {visitedFragments} is not provided, initialize it to the empty set.
433
- - Initialize {groupedFieldSet } to an empty ordered map of ordered sets.
436
+ - Initialize {collectedFieldsMap } to an empty ordered map of ordered sets.
434
437
- For each {selection} in {selectionSet}:
435
438
- If {selection} provides the directive ` @skip ` , let {skipDirective} be that
436
439
directive.
@@ -445,8 +448,9 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
445
448
- If {selection} is a {Field}:
446
449
- Let {responseName} be the _ response name_ of {selection} (the alias if
447
450
defined, otherwise the field name).
448
- - Let {fieldsForResponseName} be the _ field set_ in {groupedFieldSet} for
449
- {responseName}; if no such set exists, create it as an empty set.
451
+ - Let {fieldsForResponseName} be the _ field set_ value in
452
+ {collectedFieldsMap} for the key {responseName}; otherwise create it as an
453
+ empty ordered set.
450
454
- Append {selection} to the {fieldsForResponseName}.
451
455
- If {selection} is a {FragmentSpread}:
452
456
- Let {fragmentSpreadName} be the name of {selection}.
@@ -461,31 +465,31 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
461
465
- If {DoesFragmentTypeApply(objectType, fragmentType)} is {false}, continue
462
466
with the next {selection} in {selectionSet}.
463
467
- Let {fragmentSelectionSet} be the top-level selection set of {fragment}.
464
- - Let {fragmentGroupedFieldSet } be the result of calling
468
+ - Let {fragmentCollectedFieldMap } be the result of calling
465
469
{CollectFields(objectType, fragmentSelectionSet, variableValues,
466
470
visitedFragments)}.
467
- - For each {fragmentGroup} in {fragmentGroupedFieldSet}:
468
- - Let {responseName} be the response name shared by all fields in
469
- {fragmentGroup}.
470
- - Let {fieldsForResponseName} be the _ field set _ in {groupedFieldSet} for
471
- {responseName}; if no such set exists, create it as an empty set.
472
- - Append all items in {fragmentGroup } to {fieldsForResponseName}.
471
+ - For each {fragmentCollectedFieldMap} as {responseName} and
472
+ {fragmentFields}:
473
+ - Let {fieldsForResponseName} be the _ field set _ value in
474
+ {collectedFieldsMap} for the key {responseName}; otherwise create it as
475
+ an empty ordered set.
476
+ - Add each items from {fragmentFields } to {fieldsForResponseName}.
473
477
- If {selection} is an {InlineFragment}:
474
478
- Let {fragmentType} be the type condition on {selection}.
475
479
- If {fragmentType} is not {null} and {DoesFragmentTypeApply(objectType,
476
480
fragmentType)} is {false}, continue with the next {selection} in
477
481
{selectionSet}.
478
482
- Let {fragmentSelectionSet} be the top-level selection set of {selection}.
479
- - Let {fragmentGroupedFieldSet } be the result of calling
483
+ - Let {fragmentCollectedFieldMap } be the result of calling
480
484
{CollectFields(objectType, fragmentSelectionSet, variableValues,
481
485
visitedFragments)}.
482
- - For each {fragmentGroup} in {fragmentGroupedFieldSet}:
483
- - Let {responseName} be the response name shared by all fields in
484
- {fragmentGroup}.
485
- - Let {fieldsForResponseName} be the _ field set _ in {groupedFieldSet} for
486
- {responseName}; if no such set exists, create it as an empty set.
487
- - Append all items in {fragmentGroup } to {fieldsForResponseName}.
488
- - Return {groupedFieldSet }.
486
+ - For each {fragmentCollectedFieldMap} as {responseName} and
487
+ {fragmentFields}:
488
+ - Let {fieldsForResponseName} be the _ field set _ value in
489
+ {collectedFieldsMap} for the key {responseName}; otherwise create it as
490
+ an empty ordered set.
491
+ - Append all items in {fragmentFields } to {fieldsForResponseName}.
492
+ - Return {collectedFieldsMap }.
489
493
490
494
DoesFragmentTypeApply(objectType, fragmentType):
491
495
@@ -506,8 +510,8 @@ directives may be applied in either order since they apply commutatively.
506
510
507
511
In order to execute the sub-selections of a object typed field, all _ selection
508
512
sets_ of each field with the same response name of the parent _ field set_ are
509
- merged together into a single _ grouped field set _ representing the subfields to
510
- be executed next.
513
+ merged together into a single _ collected fields map _ representing the subfields
514
+ to be executed next.
511
515
512
516
An example operation illustrating parallel fields with the same name with
513
517
sub-selections.
@@ -536,17 +540,18 @@ phase with the same value.
536
540
537
541
CollectSubfields(objectType, fields, variableValues):
538
542
539
- - Let {groupedFieldSet } be an empty ordered map of ordered sets.
543
+ - Let {collectedFieldsMap } be an empty ordered map of ordered sets.
540
544
- For each {field} in {fields}:
541
545
- Let {fieldSelectionSet} be the selection set of {field}.
542
546
- If {fieldSelectionSet} is null or empty, continue to the next field.
543
- - Let {fieldGroupedFieldSet } be the result of {CollectFields(objectType,
547
+ - Let {fieldCollectedFieldMap } be the result of {CollectFields(objectType,
544
548
fieldSelectionSet, variableValues)}.
545
- - For each {fieldGroupedFieldSet} as {responseName} and {subfields}:
546
- - Let {fieldsForResponseName} be the _ field set_ in {groupedFieldSet} for
547
- {responseName}; if no such set exists, create it as an empty set.
548
- - Add each fields in {subfields} to {fieldsForResponseName}.
549
- - Return {groupedFieldSet}.
549
+ - For each {fieldCollectedFieldMap} as {responseName} and {subfields}:
550
+ - Let {fieldsForResponseName} be the _ field set_ value in
551
+ {collectedFieldsMap} for the key {responseName}; otherwise create it as an
552
+ empty ordered set.
553
+ - Add each fields from {subfields} to {fieldsForResponseName}.
554
+ - Return {collectedFieldsMap}.
550
555
551
556
Note: All the {fields} passed to {CollectSubfields()} share the same _ response
552
557
name_ .
@@ -555,20 +560,20 @@ name_.
555
560
556
561
The {CollectFields()} and {CollectSubfields()} algorithms transitively collect
557
562
the field selections from a _ selection set_ or the associated selection sets of
558
- a _ field set_ respectively, and split them into groups by their _ response name_
559
- to produce a _ grouped field set _ .
563
+ a _ field set_ respectively, and split them into sets by their _ response name_ to
564
+ produce a _ collected fields map _ .
560
565
561
- To execute a _ grouped field set _ , the object type being evaluated and the
566
+ To execute a _ collected fields map _ , the object type being evaluated and the
562
567
runtime value need to be known, as well as the runtime values for any variables.
563
568
564
- Each entry in the grouped field set represents a _ response name_ which produces
565
- an entry into a result map.
569
+ Each entry in the collected fields map represents a _ response name_ which
570
+ produces an entry into a result map.
566
571
567
- ExecuteCollectedFields(groupedFieldSet , objectType, objectValue,
572
+ ExecuteCollectedFields(collectedFieldsMap , objectType, objectValue,
568
573
variableValues):
569
574
570
575
- Initialize {resultMap} to an empty ordered map.
571
- - For each {groupedFieldSet } as {responseName} and {fields}:
576
+ - For each {collectedFieldsMap } as {responseName} and {fields}:
572
577
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
573
578
is unaffected if an alias is used.
574
579
- Let {fieldType} be the return type defined for the field {fieldName} of
@@ -603,13 +608,14 @@ about this behavior.
603
608
604
609
### Normal and Serial Execution
605
610
606
- Normally the executor can execute the entries in a grouped field set in whatever
607
- order it chooses (normally in parallel). Because the resolution of fields other
608
- than top-level mutation fields must always be side effect-free and idempotent,
609
- the execution order must not affect the result, and hence the service has the
610
- freedom to execute the field entries in whatever order it deems optimal.
611
+ Normally the executor can execute the entries in a collected fields map in
612
+ whatever order it chooses (normally in parallel). Because the resolution of
613
+ fields other than top-level mutation fields must always be side effect-free and
614
+ idempotent, the execution order must not affect the result, and hence the
615
+ service has the freedom to execute the field entries in whatever order it deems
616
+ optimal.
611
617
612
- For example, given the following grouped field set to be executed normally:
618
+ For example, given the following collected fields map to be executed normally:
613
619
614
620
``` graphql example
615
621
{
@@ -629,10 +635,11 @@ before `street`).
629
635
When executing a mutation, the selections in the top most selection set will be
630
636
executed in serial order, starting with the first appearing field textually.
631
637
632
- When executing a grouped field set serially, the executor must consider each
633
- entry from the grouped field set in the order provided in the grouped field set.
634
- It must determine the corresponding entry in the result map for each item to
635
- completion before it continues on to the next item in the grouped field set:
638
+ When executing a collected fields map serially, the executor must consider each
639
+ entry from the collected fields map in the order provided in the collected
640
+ fields map. It must determine the corresponding entry in the result map for each
641
+ item to completion before it continues on to the next entry in the collected
642
+ fields map:
636
643
637
644
For example, given the following mutation operation, the root _ selection set_
638
645
must be executed serially:
@@ -701,7 +708,7 @@ A correct executor must generate the following result for that _selection set_:
701
708
702
709
## Executing Fields
703
710
704
- Each field requested in the grouped field set that is defined on the selected
711
+ Each field from the _ collected fields map _ that is defined on the selected
705
712
objectType will result in an entry in the result map. Field execution first
706
713
coerces any provided argument values, then resolves a value for the field, and
707
714
finally completes that value either by recursively executing another selection
@@ -830,9 +837,9 @@ CompleteValue(fieldType, fields, result, variableValues):
830
837
- Let {objectType} be {fieldType}.
831
838
- Otherwise if {fieldType} is an Interface or Union type.
832
839
- Let {objectType} be {ResolveAbstractType(fieldType, result)}.
833
- - Let {groupedFieldSet } be the result of calling {CollectSubfields(objectType,
834
- fields, variableValues)}.
835
- - Return the result of evaluating {ExecuteCollectedFields(groupedFieldSet ,
840
+ - Let {collectedFieldsMap } be the result of calling
841
+ {CollectSubfields(objectType, fields, variableValues)}.
842
+ - Return the result of evaluating {ExecuteCollectedFields(collectedFieldsMap ,
836
843
objectType, result, variableValues)} _ normally_ (allowing for
837
844
parallelization).
838
845
0 commit comments