Skip to content

Commit ed11e66

Browse files
committed
also rename grouped field set -> collected fields map
1 parent d0fb75c commit ed11e66

File tree

2 files changed

+61
-54
lines changed

2 files changed

+61
-54
lines changed

spec/Section 5 -- Validation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ query getName {
259259
- For each subscription operation definition {subscription} in the document:
260260
- Let {selectionSet} be the top level selection set on {subscription}.
261261
- Let {variableValues} be the empty set.
262-
- Let {groupedFieldSet} be the result of {CollectFields(subscriptionType,
262+
- Let {collectedFieldsMap} be the result of {CollectFields(subscriptionType,
263263
selectionSet, variableValues)}.
264-
- {groupedFieldSet} must have exactly one entry, which must not be an
264+
- {collectedFieldsMap} must have exactly one entry, which must not be an
265265
introspection field.
266266

267267
**Explanatory Text**

spec/Section 6 -- Execution.md

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,11 @@ CreateSourceEventStream(subscription, schema, variableValues, initialValue):
268268
- Let {subscriptionType} be the root Subscription type in {schema}.
269269
- Assert: {subscriptionType} is an Object type.
270270
- 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,
272272
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}.
275276
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
276277
is unaffected if an alias is used.
277278
- Let {field} be the first entry in {fields}.
@@ -368,31 +369,32 @@ Executing the root selection set works similarly for queries (parallel),
368369
mutations (serial), and subscriptions (where it is executed for each event in
369370
the underlying Source Stream).
370371

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}.
373374

374375
ExecuteRootSelectionSet(variableValues, initialValue, objectType, selectionSet,
375376
executionMode):
376377

377-
- Let {groupedFieldSet} be the result of {CollectFields(objectType,
378+
- Let {collectedFieldsMap} be the result of {CollectFields(objectType,
378379
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)).
382384
- Let {errors} be the list of all _execution error_ raised while executing the
383385
selection set.
384386
- Return an unordered map containing {data} and {errors}.
385387

386388
### Field Collection
387389

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.
391393

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 a map where each entry is a _response name_ and
395+
its associated _field set_. A _collected fields map_ may be produced from a
396+
selection set via {CollectFields()} or from the selection sets of a _field set_
397+
via {CollectSubfields()}.
396398

397399
:: A _field set_ is an ordered set of selected fields that share the same
398400
_response name_ (the field alias if defined, otherwise the field's name).
@@ -404,8 +406,8 @@ Note: The order of field selections in a _field set_ is significant, hence the
404406
algorithms in this specification model it as an ordered set.
405407

406408
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`:
409+
in a collected fields map with two entries, `"a"` and `"b"`, with two instances
410+
of the field `a` and one of field `b`:
409411

410412
```graphql example
411413
{
@@ -430,7 +432,7 @@ response in a stable and predictable order.
430432
CollectFields(objectType, selectionSet, variableValues, visitedFragments):
431433

432434
- If {visitedFragments} is not provided, initialize it to the empty set.
433-
- Initialize {groupedFieldSet} to an empty ordered map of ordered sets.
435+
- Initialize {collectedFieldsMap} to an empty ordered map of ordered sets.
434436
- For each {selection} in {selectionSet}:
435437
- If {selection} provides the directive `@skip`, let {skipDirective} be that
436438
directive.
@@ -445,8 +447,9 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
445447
- If {selection} is a {Field}:
446448
- Let {responseName} be the _response name_ of {selection} (the alias if
447449
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.
450+
- Let {fieldsForResponseName} be the _field set_ value in
451+
{collectedFieldsMap} for the key {responseName}; otherwise create it as an
452+
empty ordered set.
450453
- Append {selection} to the {fieldsForResponseName}.
451454
- If {selection} is a {FragmentSpread}:
452455
- Let {fragmentSpreadName} be the name of {selection}.
@@ -467,8 +470,9 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
467470
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
468471
- Let {responseName} be the response name shared by all fields in
469472
{fragmentGroup}.
470-
- Let {fieldsForResponseName} be the _field set_ in {groupedFieldSet} for
471-
{responseName}; if no such set exists, create it as an empty set.
473+
- Let {fieldsForResponseName} be the _field set_ value in
474+
{collectedFieldsMap} for the key {responseName}; otherwise create it as
475+
an empty ordered set.
472476
- Append all items in {fragmentGroup} to {fieldsForResponseName}.
473477
- If {selection} is an {InlineFragment}:
474478
- Let {fragmentType} be the type condition on {selection}.
@@ -482,10 +486,11 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
482486
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
483487
- Let {responseName} be the response name shared by all fields in
484488
{fragmentGroup}.
485-
- Let {fieldsForResponseName} be the _field set_ in {groupedFieldSet} for
486-
{responseName}; if no such set exists, create it as an empty set.
489+
- Let {fieldsForResponseName} be the _field set_ value in
490+
{collectedFieldsMap} for the key {responseName}; otherwise create it as
491+
an empty ordered set.
487492
- Append all items in {fragmentGroup} to {fieldsForResponseName}.
488-
- Return {groupedFieldSet}.
493+
- Return {collectedFieldsMap}.
489494

490495
DoesFragmentTypeApply(objectType, fragmentType):
491496

@@ -506,8 +511,8 @@ directives may be applied in either order since they apply commutatively.
506511

507512
In order to execute the sub-selections of a object typed field, all _selection
508513
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.
514+
merged together into a single _collected fields map_ representing the subfields
515+
to be executed next.
511516

512517
An example operation illustrating parallel fields with the same name with
513518
sub-selections.
@@ -536,17 +541,17 @@ phase with the same value.
536541

537542
CollectSubfields(objectType, fields, variableValues):
538543

539-
- Let {groupedFieldSet} be an empty ordered map of ordered sets.
544+
- Let {collectedFieldsMap} be an empty ordered map of ordered sets.
540545
- For each {field} in {fields}:
541546
- Let {fieldSelectionSet} be the selection set of {field}.
542547
- If {fieldSelectionSet} is null or empty, continue to the next field.
543548
- Let {fieldGroupedFieldSet} be the result of {CollectFields(objectType,
544549
fieldSelectionSet, variableValues)}.
545550
- 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.
551+
- Let {fieldsForResponseName} be the _field set_ value in {collectedFieldsMap} for
552+
the key {responseName}; otherwise create it as an empty ordered set.
548553
- Add each fields in {subfields} to {fieldsForResponseName}.
549-
- Return {groupedFieldSet}.
554+
- Return {collectedFieldsMap}.
550555

551556
Note: All the {fields} passed to {CollectSubfields()} share the same _response
552557
name_.
@@ -556,19 +561,19 @@ name_.
556561
The {CollectFields()} and {CollectSubfields()} algorithms transitively collect
557562
the field selections from a _selection set_ or the associated selection sets of
558563
a _field set_ respectively, and split them into groups by their _response name_
559-
to produce a _grouped field set_.
564+
to produce a _collected fields map_.
560565

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
562567
runtime value need to be known, as well as the runtime values for any variables.
563568

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.
566571

567-
ExecuteCollectedFields(groupedFieldSet, objectType, objectValue,
572+
ExecuteCollectedFields(collectedFieldsMap, objectType, objectValue,
568573
variableValues):
569574

570575
- Initialize {resultMap} to an empty ordered map.
571-
- For each {groupedFieldSet} as {responseName} and {fields}:
576+
- For each {collectedFieldsMap} as {responseName} and {fields}:
572577
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
573578
is unaffected if an alias is used.
574579
- Let {fieldType} be the return type defined for the field {fieldName} of
@@ -603,13 +608,14 @@ about this behavior.
603608

604609
### Normal and Serial Execution
605610

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.
611617

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:
613619

614620
```graphql example
615621
{
@@ -629,10 +635,11 @@ before `street`).
629635
When executing a mutation, the selections in the top most selection set will be
630636
executed in serial order, starting with the first appearing field textually.
631637

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:
636643

637644
For example, given the following mutation operation, the root _selection set_
638645
must be executed serially:
@@ -701,7 +708,7 @@ A correct executor must generate the following result for that _selection set_:
701708

702709
## Executing Fields
703710

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
705712
objectType will result in an entry in the result map. Field execution first
706713
coerces any provided argument values, then resolves a value for the field, and
707714
finally completes that value either by recursively executing another selection
@@ -830,9 +837,9 @@ CompleteValue(fieldType, fields, result, variableValues):
830837
- Let {objectType} be {fieldType}.
831838
- Otherwise if {fieldType} is an Interface or Union type.
832839
- 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,
836843
objectType, result, variableValues)} _normally_ (allowing for
837844
parallelization).
838845

0 commit comments

Comments
 (0)