@@ -32,8 +32,7 @@ free of any validation errors, and have not changed since.
3232
3333** Examples**
3434
35- For this section of this schema, we will assume the following type system in
36- order to demonstrate examples:
35+ The examples in this section will use the following types:
3736
3837``` graphql example
3938type Query {
@@ -303,24 +302,25 @@ query getName {
303302- Let {subscriptionType} be the root Subscription type in {schema}.
304303- For each subscription operation definition {subscription} in the document:
305304 - Let {selectionSet} be the top level selection set on {subscription}.
306- - Let {groupedFieldSet } be the result of
305+ - Let {collectedFieldsMap } be the result of
307306 {CollectSubscriptionFields(subscriptionType, selectionSet)}.
308- - {groupedFieldSet } must have exactly one entry, which must not be an
307+ - {collectedFieldsMap } must have exactly one entry, which must not be an
309308 introspection field.
310309
311310CollectSubscriptionFields(objectType, selectionSet, visitedFragments):
312311
313312- If {visitedFragments} is not provided, initialize it to the empty set.
314- - Initialize {groupedFields } to an empty ordered map of lists .
313+ - Initialize {collectedFieldsMap } to an empty ordered map of ordered sets .
315314- For each {selection} in {selectionSet}:
316315 - {selection} must not provide the ` @skip ` directive.
317316 - {selection} must not provide the ` @include ` directive.
318317 - If {selection} is a {Field}:
319- - Let {responseKey } be the response key of {selection} (the alias if
318+ - Let {responseName } be the _ response name _ of {selection} (the alias if
320319 defined, otherwise the field name).
321- - Let {groupForResponseKey} be the list in {groupedFields} for
322- {responseKey}; if no such list exists, create it as an empty list.
323- - Append {selection} to the {groupForResponseKey}.
320+ - Let {fieldsForResponseKey} be the _ field set_ value in
321+ {collectedFieldsMap} for the key {responseName}; otherwise create the
322+ entry with an empty ordered set.
323+ - Add {selection} to the {fieldsForResponseKey}.
324324 - If {selection} is a {FragmentSpread}:
325325 - Let {fragmentSpreadName} be the name of {selection}.
326326 - If {fragmentSpreadName} is in {visitedFragments}, continue with the next
@@ -334,31 +334,31 @@ CollectSubscriptionFields(objectType, selectionSet, visitedFragments):
334334 - If {DoesFragmentTypeApply(objectType, fragmentType)} is {false}, continue
335335 with the next {selection} in {selectionSet}.
336336 - Let {fragmentSelectionSet} be the top-level selection set of {fragment}.
337- - Let {fragmentGroupedFieldSet } be the result of calling
337+ - Let {fragmentCollectedFieldsMap } be the result of calling
338338 {CollectSubscriptionFields(objectType, fragmentSelectionSet,
339339 visitedFragments)}.
340- - For each {fragmentGroup} in {fragmentGroupedFieldSet}:
341- - Let {responseKey} be the response key shared by all fields in
342- {fragmentGroup}.
343- - Let {groupForResponseKey} be the list in {groupedFields} for
344- {responseKey}; if no such list exists, create it as an empty list .
345- - Append all items in {fragmentGroup } to {groupForResponseKey }.
340+ - For each {responseName} and {fragmentFields} in
341+ {fragmentCollectedFieldsMap}:
342+ - Let {fieldsForResponseKey} be the _ field set _ value in
343+ {collectedFieldsMap} for the key {responseName}; otherwise create the
344+ entry with an empty ordered set .
345+ - Add each item from {fragmentFields } to {fieldsForResponseKey }.
346346 - If {selection} is an {InlineFragment}:
347347 - Let {fragmentType} be the type condition on {selection}.
348348 - If {fragmentType} is not {null} and {DoesFragmentTypeApply(objectType,
349349 fragmentType)} is {false}, continue with the next {selection} in
350350 {selectionSet}.
351351 - Let {fragmentSelectionSet} be the top-level selection set of {selection}.
352- - Let {fragmentGroupedFieldSet } be the result of calling
352+ - Let {fragmentCollectedFieldsMap } be the result of calling
353353 {CollectSubscriptionFields(objectType, fragmentSelectionSet,
354354 visitedFragments)}.
355- - For each {fragmentGroup} in {fragmentGroupedFieldSet}:
356- - Let {responseKey} be the response key shared by all fields in
357- {fragmentGroup}.
358- - Let {groupForResponseKey} be the list in {groupedFields} for
359- {responseKey}; if no such list exists, create it as an empty list .
360- - Append all items in {fragmentGroup } to {groupForResponseKey }.
361- - Return {groupedFields }.
355+ - For each {responseName} and {fragmentFields} in
356+ {fragmentCollectedFieldsMap}:
357+ - Let {fieldsForResponseKey} be the _ field set _ value in
358+ {collectedFieldsMap} for the key {responseName}; otherwise create the
359+ entry with an empty ordered set .
360+ - Add each item from {fragmentFields } to {fieldsForResponseKey }.
361+ - Return {collectedFieldsMap }.
362362
363363Note: This algorithm is very similar to {CollectFields()}, it differs in that it
364364does not have access to runtime variables and thus the ` @skip ` and ` @include `
@@ -584,7 +584,7 @@ should be unambiguous. Therefore any two field selections which might both be
584584encountered for the same object are only valid if they are equivalent.
585585
586586During execution, the simultaneous execution of fields with the same response
587- name is accomplished by {MergeSelectionSets ()} and {CollectFields()} .
587+ name is accomplished by performing {CollectSubfields ()} before their execution .
588588
589589For simple hand-written GraphQL, this rule is obviously a clear developer error,
590590however nested fragments can make this difficult to detect manually.
0 commit comments