Executing Operations
The type system, as described in the “Type System” section of the spec, must provide a query root object type. If mutations are supported, it must also provide a mutation root object type.
If the operation is a query, the result of the operation is the result of executing the query’s top level selection set with the query root object type.
An initial value may be provided when executing a query.
(
query
,
schema
,
variableValues
,
initialValue
)
- Let queryType be the root Query type in schema .
- Assert: queryType is an Object type.
- Let selectionSet be the top level Selection Set in query .
- Let data be the result of running ExecuteSelectionSet ( selectionSet , queryType , initialValue , variableValues ) normally (allowing parallelization).
- Let errors be any field errors produced while executing the selection set.
- Return an unordered map containing data and errors .
If the operation is a mutation, the result of the operation is the result of executing the mutation’s top level selection set on the mutation root object type. This selection set should be executed serially.
It is expected that the top level fields in a mutation operation perform side‐effects on the underlying data system. Serial execution of the provided mutations ensures against race conditions during these side‐effects.
(
mutation
,
schema
,
variableValues
,
initialValue
)
- Let mutationType be the root Mutation type in schema .
- Assert: mutationType is an Object type.
- Let selectionSet be the top level Selection Set in mutation .
- Let data be the result of running ExecuteSelectionSet ( selectionSet , mutationType , initialValue , variableValues ) serially .
- Let errors be any field errors produced while executing the selection set.
- Return an unordered map containing data and errors .