2015-07-15 20:05:46 +03:00
|
|
|
<?php
|
|
|
|
namespace GraphQL\Executor;
|
|
|
|
|
2015-08-17 17:01:55 +03:00
|
|
|
use GraphQL\Error;
|
2015-07-15 20:05:46 +03:00
|
|
|
use GraphQL\Language\AST\OperationDefinition;
|
|
|
|
use GraphQL\Schema;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Data that must be available at all points during query execution.
|
|
|
|
*
|
|
|
|
* Namely, schema of the type system that is currently executing,
|
|
|
|
* and the fragments defined in the query document
|
|
|
|
*/
|
|
|
|
class ExecutionContext
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var Schema
|
|
|
|
*/
|
|
|
|
public $schema;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array<string, FragmentDefinition>
|
|
|
|
*/
|
|
|
|
public $fragments;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var
|
|
|
|
*/
|
2015-08-17 17:01:55 +03:00
|
|
|
public $rootValue;
|
2015-07-15 20:05:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var OperationDefinition
|
|
|
|
*/
|
|
|
|
public $operation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-08-17 17:01:55 +03:00
|
|
|
public $variableValues;
|
2015-07-15 20:05:46 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
public $errors;
|
|
|
|
|
|
|
|
public function __construct($schema, $fragments, $root, $operation, $variables, $errors)
|
|
|
|
{
|
|
|
|
$this->schema = $schema;
|
|
|
|
$this->fragments = $fragments;
|
2015-08-17 17:01:55 +03:00
|
|
|
$this->rootValue = $root;
|
2015-07-15 20:05:46 +03:00
|
|
|
$this->operation = $operation;
|
2015-08-17 17:01:55 +03:00
|
|
|
$this->variableValues = $variables;
|
2015-07-15 20:05:46 +03:00
|
|
|
$this->errors = $errors ?: [];
|
|
|
|
}
|
|
|
|
|
2015-08-17 17:01:55 +03:00
|
|
|
public function addError(Error $error)
|
2015-07-15 20:05:46 +03:00
|
|
|
{
|
|
|
|
$this->errors[] = $error;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|