Executing Selection Sets
To execute a selection set, the object value being evaluated and the object type need to be known, as well as whether it must be executed serially, or may be executed in parallel.
First, the selection set is turned into a grouped field set; then, each represented field in the grouped field set produces an entry into a response map.
(
selectionSet
,
objectType
,
objectValue
,
variableValues
)
- Let groupedFieldSet be the result of CollectFields ( objectType , selectionSet , variableValues ) .
- Initialize resultMap to an empty ordered map.
- For each
groupedFieldSet
as
responseKey
and
fields
:
- Let fieldName be the name of the first entry in fields . Note: This value is unaffected if an alias is used.
- Let fieldType be the return type defined for the field fieldName of objectType .
- If
fieldType
is
null
:
- Continue to the next iteration of groupedFieldSet .
- Let responseValue be ExecuteField ( objectType , objectValue , fields , fieldType , variableValues ) .
- Set responseValue as the value for responseKey in resultMap .
- Return resultMap .
responseMap
is ordered by which fields appear first in the query. This is explained in greater detail in the Field Collection section below.