@@ -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,10 @@ 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.
471- - Append all fields in {fragmentFieldSet} to {fieldSet}.
464+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
465+ such set exists, create it as an empty ordered set.
466+ - Add each field in {fragmentFieldSet} to {fieldSet}, if not already
467+ present.
472468 - If {selection} is an {InlineFragment}:
473469 - Let {fragmentType} be the type condition on {selection}.
474470 - If {fragmentType} is not {null} and {DoesFragmentTypeApply(objectType,
@@ -480,9 +476,10 @@ CollectFields(objectType, selectionSet, variableValues, visitedFragments):
480476 visitedFragments)}.
481477 - For each {fragmentGroupedFieldSet} as {responseName} and
482478 {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}.
479+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
480+ such set exists, create it as an empty ordered set.
481+ - Add each field in {fragmentFieldSet} to {fieldSet}, if not already
482+ present.
486483- Return {groupedFieldSet}.
487484
488485DoesFragmentTypeApply(objectType, fragmentType):
@@ -541,13 +538,13 @@ CollectSubfields(objectType, fieldSet, variableValues):
541538 - Let {fieldGroupedFieldSet} be the result of {CollectFields(objectType,
542539 fieldSelectionSet, variableValues)}.
543540 - 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}.
541+ - Let {fieldSet} be the set in {groupedFieldSet} for {responseName}; if no
542+ such set exists, create it as an empty ordered set .
543+ - Add each field in {subfields} to {fieldSet}, if not already present .
547544- Return {groupedFieldSet}.
548545
549- Note: The {fieldSet} passed to {CollectSubfields()} is a _ field set_ , thus they
550- share the same _ response name_ .
546+ Note: The {fieldSet} passed to {CollectSubfields()} is a _ field set_ , thus each
547+ {field} will share the same _ response name_ .
551548
552549### Executing Collected Fields
553550
0 commit comments