Executing Requests
To execute a request, the executor must have a parsedDocument(as defined in the “Query Language” part of this spec) and a selected operation name to run if the document defines multiple operations, otherwise the document is expected to only contain a single operation. The result of the request is determined by the result of executing this operation according to the “Executing Operations” section below.
(
schema
,
document
,
operationName
,
variableValues
,
initialValue
)
- Let operation be the result of GetOperation ( document , operationName ) .
 - Let coercedVariableValues be the result of CoerceVariableValues ( schema , operation , variableValues ) .
 - If
operation
is a query operation:
- Return ExecuteQuery ( operation , schema , coercedVariableValues , initialValue ) .
 
 - Otherwise if
operation
is a mutation operation:
- Return ExecuteMutation ( operation , schema , coercedVariableValues , initialValue ) .
 
 
(
document
,
operationName
)
- If
operationName
is
null
:
- If
document
contains exactly one operation.
- Return the Operation contained in the document .
 
 - Otherwise produce a query error requiring operationName .
 
 - If
document
contains exactly one operation.
 - Otherwise:
- Let operation be the Operation named operationName in document .
 - If operation was not found, produce a query error.
 - Return operation .