Skip to content

Commit 4390617

Browse files
benjieleebyron
andauthored
Consistently use 'response name' not 'response key' (#1147)
* Consistently use 'response key' not 'response name' * Extract definition of response key from #1039 * Utilise definition * response key -> response name * Fix names in algorithms * latest changes --------- Co-authored-by: Lee Byron <[email protected]>
1 parent 521ef5b commit 4390617

4 files changed

+27
-26
lines changed

spec/Section 2 -- Language.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,9 @@ These two operations are semantically identical:
466466

467467
Alias : Name :
468468

469-
By default a field's response key in the response object will use that field's
470-
name. However, you can define a different response key by specifying an alias.
469+
:: A _response name_ is the key in the response object which correlates with a
470+
field's result. By default the response name will use the field's name; however,
471+
you can define a different response name by specifying an alias.
471472

472473
In this example, we can fetch two profile pictures of different sizes and ensure
473474
the resulting response object will not have duplicate keys:

spec/Section 5 -- Validation.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ fragment directFieldSelectionOnUnion on CatOrDog {
418418

419419
FieldsInSetCanMerge(set):
420420

421-
- Let {fieldsForName} be the set of selections with a given response name in
421+
- Let {fieldsForName} be the set of selections with a given _response name_ in
422422
{set} including visiting fragments and inline fragments.
423423
- Given each pair of distinct members {fieldA} and {fieldB} in {fieldsForName}:
424424
- {SameResponseShape(fieldA, fieldB)} must be true.
@@ -450,7 +450,7 @@ SameResponseShape(fieldA, fieldB):
450450
- Assert: {typeB} is an object, union or interface type.
451451
- Let {mergedSet} be the result of adding the selection set of {fieldA} and the
452452
selection set of {fieldB}.
453-
- Let {fieldsForName} be the set of selections with a given response name in
453+
- Let {fieldsForName} be the set of selections with a given _response name_ in
454454
{mergedSet} including visiting fragments and inline fragments.
455455
- Given each pair of distinct members {subfieldA} and {subfieldB} in
456456
{fieldsForName}:
@@ -462,10 +462,10 @@ type that is either an Object, Interface or Union type.
462462

463463
**Explanatory Text**
464464

465-
If multiple field selections with the same response names are encountered during
466-
execution, the field and arguments to execute and the resulting value should be
467-
unambiguous. Therefore any two field selections which might both be encountered
468-
for the same object are only valid if they are equivalent.
465+
If multiple field selections with the same _response name_ are encountered
466+
during execution, the field and arguments to execute and the resulting value
467+
should be unambiguous. Therefore any two field selections which might both be
468+
encountered for the same object are only valid if they are equivalent.
469469

470470
During execution, the simultaneous execution of fields with the same response
471471
name is accomplished by {MergeSelectionSets()} and {CollectFields()}.

spec/Section 6 -- Execution.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -362,15 +362,15 @@ ExecuteSelectionSet(selectionSet, objectType, objectValue, variableValues):
362362
- Let {groupedFieldSet} be the result of {CollectFields(objectType,
363363
selectionSet, variableValues)}.
364364
- Initialize {resultMap} to an empty ordered map.
365-
- For each {groupedFieldSet} as {responseKey} and {fields}:
365+
- For each {groupedFieldSet} as {responseName} and {fields}:
366366
- Let {fieldName} be the name of the first entry in {fields}. Note: This value
367367
is unaffected if an alias is used.
368368
- Let {fieldType} be the return type defined for the field {fieldName} of
369369
{objectType}.
370370
- If {fieldType} is defined:
371371
- Let {responseValue} be {ExecuteField(objectType, objectValue, fieldType,
372372
fields, variableValues)}.
373-
- Set {responseValue} as the value for {responseKey} in {resultMap}.
373+
- Set {responseValue} as the value for {responseName} in {resultMap}.
374374
- Return {resultMap}.
375375

376376
Note: {resultMap} is ordered by which fields appear first in the operation. This
@@ -496,8 +496,8 @@ A correct executor must generate the following result for that _selection set_:
496496

497497
Before execution, the _selection set_ is converted to a grouped field set by
498498
calling {CollectFields()}. Each entry in the grouped field set is a list of
499-
fields that share a response key (the alias if defined, otherwise the field
500-
name). This ensures all fields with the same response key (including those in
499+
fields that share a _response name_ (the alias if defined, otherwise the field
500+
name). This ensures all fields with the same response name (including those in
501501
referenced fragments) are executed at the same time.
502502

503503
As an example, collecting the fields of this selection set would collect two
@@ -539,11 +539,11 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
539539
in {variableValues} with the value {true}, continue with the next
540540
{selection} in {selectionSet}.
541541
- If {selection} is a {Field}:
542-
- Let {responseKey} be the response key of {selection} (the alias if
542+
- Let {responseName} be the _response name_ of {selection} (the alias if
543543
defined, otherwise the field name).
544-
- Let {groupForResponseKey} be the list in {groupedFields} for
545-
{responseKey}; if no such list exists, create it as an empty list.
546-
- Append {selection} to the {groupForResponseKey}.
544+
- Let {groupForResponseName} be the list in {groupedFields} for
545+
{responseName}; if no such list exists, create it as an empty list.
546+
- Append {selection} to the {groupForResponseName}.
547547
- If {selection} is a {FragmentSpread}:
548548
- Let {fragmentSpreadName} be the name of {selection}.
549549
- If {fragmentSpreadName} is in {visitedFragments}, continue with the next
@@ -561,11 +561,11 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
561561
{CollectFields(objectType, fragmentSelectionSet, variableValues,
562562
visitedFragments)}.
563563
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
564-
- Let {responseKey} be the response key shared by all fields in
564+
- Let {responseName} be the response name shared by all fields in
565565
{fragmentGroup}.
566-
- Let {groupForResponseKey} be the list in {groupedFields} for
567-
{responseKey}; if no such list exists, create it as an empty list.
568-
- Append all items in {fragmentGroup} to {groupForResponseKey}.
566+
- Let {groupForResponseName} be the list in {groupedFields} for
567+
{responseName}; if no such list exists, create it as an empty list.
568+
- Append all items in {fragmentGroup} to {groupForResponseName}.
569569
- If {selection} is an {InlineFragment}:
570570
- Let {fragmentType} be the type condition on {selection}.
571571
- If {fragmentType} is not {null} and {DoesFragmentTypeApply(objectType,
@@ -576,11 +576,11 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
576576
{CollectFields(objectType, fragmentSelectionSet, variableValues,
577577
visitedFragments)}.
578578
- For each {fragmentGroup} in {fragmentGroupedFieldSet}:
579-
- Let {responseKey} be the response key shared by all fields in
579+
- Let {responseName} be the response name shared by all fields in
580580
{fragmentGroup}.
581-
- Let {groupForResponseKey} be the list in {groupedFields} for
582-
{responseKey}; if no such list exists, create it as an empty list.
583-
- Append all items in {fragmentGroup} to {groupForResponseKey}.
581+
- Let {groupForResponseName} be the list in {groupedFields} for
582+
{responseName}; if no such list exists, create it as an empty list.
583+
- Append all items in {fragmentGroup} to {groupForResponseName}.
584584
- Return {groupedFields}.
585585

586586
DoesFragmentTypeApply(objectType, fragmentType):

spec/Section 7 -- Response.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ of a {ExecuteSelectionSet()}, or it is a position in a (potentially nested) List
5656
value. Each response position is uniquely identifiable via a _response path_.
5757

5858
:: A _response path_ uniquely identifies a _response position_ via a list of
59-
path segments (response keys or list indices) starting at the root of the
59+
path segments (response names or list indices) starting at the root of the
6060
response and ending with the associated response position.
6161

6262
The value for a _response path_ must be a list of path segments. Path segments
63-
that represent field response keys must be strings, and path segments that
63+
that represent field _response name_ must be strings, and path segments that
6464
represent list indices must be 0-indexed integers. If a path segment is
6565
associated with an aliased field it must use the aliased name, since it
6666
represents a path in the response, not in the request.

0 commit comments

Comments
 (0)