GraphQL\Executor\Executor::buildExecutionContext PHP Method

buildExecutionContext() private static method

Constructs a ExecutionContext object from the arguments passed to execute, which we will pass throughout the other execution methods.
private static buildExecutionContext ( Schema $schema, DocumentNode $documentNode, $rootValue, $contextValue, $rawVariableValues, string $operationName = null ) : ExecutionContext
$schema GraphQL\Schema
$documentNode GraphQL\Language\AST\DocumentNode
$rootValue
$contextValue
$rawVariableValues
$operationName string
return ExecutionContext
    private static function buildExecutionContext(Schema $schema, DocumentNode $documentNode, $rootValue, $contextValue, $rawVariableValues, $operationName = null)
    {
        $errors = [];
        $fragments = [];
        $operation = null;
        foreach ($documentNode->definitions as $definition) {
            switch ($definition->kind) {
                case NodeKind::OPERATION_DEFINITION:
                    if (!$operationName && $operation) {
                        throw new Error('Must provide operation name if query contains multiple operations.');
                    }
                    if (!$operationName || isset($definition->name) && $definition->name->value === $operationName) {
                        $operation = $definition;
                    }
                    break;
                case NodeKind::FRAGMENT_DEFINITION:
                    $fragments[$definition->name->value] = $definition;
                    break;
                default:
                    throw new Error("GraphQL cannot execute a request containing a {$definition->kind}.", [$definition]);
            }
        }
        if (!$operation) {
            if ($operationName) {
                throw new Error("Unknown operation named \"{$operationName}\".");
            } else {
                throw new Error('Must provide an operation.');
            }
        }
        $variableValues = Values::getVariableValues($schema, $operation->variableDefinitions ?: [], $rawVariableValues ?: []);
        $exeContext = new ExecutionContext($schema, $fragments, $rootValue, $contextValue, $operation, $variableValues, $errors);
        return $exeContext;
    }