@@ -395,13 +395,8 @@ associated _field set_. A _grouped field set_ may be produced from a selection
395395set via {CollectFields()} or from the selection sets of a _ field set_ via
396396{CollectSubfields()}.
397397
398- :: A _ field set_ is a list of selected fields that share the same _ response
399- name_ (the field alias if defined, otherwise the field's name).
400-
401- Note: The order of field selections in a _ field set_ is significant, hence the
402- algorithms in this specification model it as a list. Any later duplicated field
403- selections in a field set will not impact its interpretation, so using an
404- ordered set would yield equivalent results.
398+ :: A _ field set_ is an ordered set of selected fields that share the same
399+ _ response name_ (the field alias if defined, otherwise the field's name).
405400
406401As an example, collecting the fields of this query's selection set would result
407402in a grouped field set with two entries, ` "a" ` and ` "b" ` , with two instances of
@@ -445,9 +440,9 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
445440 - If {selection} is a {Field}:
446441 - Let {responseName} be the _ response name_ of {selection} (the alias if
447442 defined, otherwise the field name).
448- - Let {fieldSet} be the list in {groupedFieldSet} for {responseName}; if no
449- such list exists, create it as an empty list .
450- - Append {selection} to {fieldSet}.
443+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
444+ such set exists, create it as an empty ordered set .
445+ - Add {selection} to {fieldSet}, if not already present .
451446 - If {selection} is a {FragmentSpread}:
452447 - Let {fragmentSpreadName} be the name of {selection}.
453448 - If {fragmentSpreadName} is in {visitedFragments}, continue with the next
@@ -466,9 +461,11 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
466461 visitedFragments)}.
467462 - For each {fragmentGroupedFieldSet} as {responseName} and
468463 {fragmentFieldSet}:
469- - Let {fieldSet} be the list in {groupedFieldSet} for {responseName}; if
470- no such list exists, create it as an empty list .
464+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
465+ such set exists, create it as an empty ordered set .
471466 - Append all fields in {fragmentFieldSet} to {fieldSet}.
467+ - Add each field in {fragmentFieldSet} to {fieldSet}, if not already
468+ present.
472469 - If {selection} is an {InlineFragment}:
473470 - Let {fragmentType} be the type condition on {selection}.
474471 - If {fragmentType} is not {null} and {DoesFragmentTypeApply(objectType,
@@ -480,9 +477,10 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
480477 visitedFragments)}.
481478 - For each {fragmentGroupedFieldSet} as {responseName} and
482479 {fragmentFieldSet}:
483- - Let {fieldSet} be the list in {groupedFieldSet} for {responseName}; if
484- no such list exists, create it as an empty list.
485- - Append all fields in {fragmentFieldSet} to {fieldSet}.
480+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
481+ such set exists, create it as an empty ordered set.
482+ - Add each field in {fragmentFieldSet} to {fieldSet}, if not already
483+ present.
486484- Return {groupedFieldSet}.
487485
488486DoesFragmentTypeApply(objectType, fragmentType):
@@ -541,13 +539,13 @@ CollectSubfields(objectType, fieldSet, variableValues):
541539 - Let {fieldGroupedFieldSet} be the result of {CollectFields(objectType,
542540 fieldSelectionSet, variableValues)}.
543541 - For each {fieldGroupedFieldSet} as {responseName} and {subfields}:
544- - Let {fieldSet} be the list in {groupedFieldSet} for {responseName}; if no
545- such list exists, create it as an empty list .
546- - Append all fields in {subfields} to {fieldSet}.
542+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
543+ such set exists, create it as an empty ordered set .
544+ - Add each field in {subfields} to {fieldSet}, if not already present .
547545- Return {groupedFieldSet}.
548546
549- Note: The {fieldSet} passed to {CollectSubfields()} is a _ field set_ , thus they
550- share the same _ response name_ .
547+ Note: The {fieldSet} passed to {CollectSubfields()} is a _ field set_ , thus each
548+ {field} will share the same _ response name_ .
551549
552550### Executing Collected Fields
553551
0 commit comments