Promise
2 months ago
ExecutionContext.php
2 months ago
ExecutionResult.php
2 months ago
Executor.php
2 months ago
ExecutorImplementation.php
2 months ago
PromiseExecutor.php
2 months ago
ReferenceExecutor.php
2 months ago
ScopedContext.php
2 months ago
Values.php
2 months ago
ExecutionContext.php
95 lines
| 1 | <?php declare(strict_types=1); |
| 2 | |
| 3 | namespace Automattic\WooCommerce\Vendor\GraphQL\Executor; |
| 4 | |
| 5 | use Automattic\WooCommerce\Vendor\GraphQL\Error\Error; |
| 6 | use Automattic\WooCommerce\Vendor\GraphQL\Executor\Promise\PromiseAdapter; |
| 7 | use Automattic\WooCommerce\Vendor\GraphQL\Language\AST\FragmentDefinitionNode; |
| 8 | use Automattic\WooCommerce\Vendor\GraphQL\Language\AST\OperationDefinitionNode; |
| 9 | use Automattic\WooCommerce\Vendor\GraphQL\Type\Schema; |
| 10 | |
| 11 | /** |
| 12 | * Data that must be available at all points during query execution. |
| 13 | * |
| 14 | * Namely, schema of the type system that is currently executing, |
| 15 | * and the fragments defined in the query document. |
| 16 | * |
| 17 | * @phpstan-import-type FieldResolver from Executor |
| 18 | * @phpstan-import-type ArgsMapper from Executor |
| 19 | */ |
| 20 | class ExecutionContext |
| 21 | { |
| 22 | public Schema $schema; |
| 23 | |
| 24 | /** @var array<string, FragmentDefinitionNode> */ |
| 25 | public array $fragments; |
| 26 | |
| 27 | /** @var mixed */ |
| 28 | public $rootValue; |
| 29 | |
| 30 | /** @var mixed */ |
| 31 | public $contextValue; |
| 32 | |
| 33 | public OperationDefinitionNode $operation; |
| 34 | |
| 35 | /** @var array<string, mixed> */ |
| 36 | public array $variableValues; |
| 37 | |
| 38 | /** |
| 39 | * @var callable |
| 40 | * |
| 41 | * @phpstan-var FieldResolver |
| 42 | */ |
| 43 | public $fieldResolver; |
| 44 | |
| 45 | /** |
| 46 | * @var callable |
| 47 | * |
| 48 | * @phpstan-var ArgsMapper |
| 49 | */ |
| 50 | public $argsMapper; |
| 51 | |
| 52 | /** @var list<Error> */ |
| 53 | public array $errors; |
| 54 | |
| 55 | public PromiseAdapter $promiseAdapter; |
| 56 | |
| 57 | /** |
| 58 | * @param array<string, FragmentDefinitionNode> $fragments |
| 59 | * @param mixed $rootValue |
| 60 | * @param mixed $contextValue |
| 61 | * @param array<string, mixed> $variableValues |
| 62 | * @param list<Error> $errors |
| 63 | * |
| 64 | * @phpstan-param FieldResolver $fieldResolver |
| 65 | */ |
| 66 | public function __construct( |
| 67 | Schema $schema, |
| 68 | array $fragments, |
| 69 | $rootValue, |
| 70 | $contextValue, |
| 71 | OperationDefinitionNode $operation, |
| 72 | array $variableValues, |
| 73 | array $errors, |
| 74 | callable $fieldResolver, |
| 75 | callable $argsMapper, |
| 76 | PromiseAdapter $promiseAdapter |
| 77 | ) { |
| 78 | $this->schema = $schema; |
| 79 | $this->fragments = $fragments; |
| 80 | $this->rootValue = $rootValue; |
| 81 | $this->contextValue = $contextValue; |
| 82 | $this->operation = $operation; |
| 83 | $this->variableValues = $variableValues; |
| 84 | $this->errors = $errors; |
| 85 | $this->fieldResolver = $fieldResolver; |
| 86 | $this->argsMapper = $argsMapper; |
| 87 | $this->promiseAdapter = $promiseAdapter; |
| 88 | } |
| 89 | |
| 90 | public function addError(Error $error): void |
| 91 | { |
| 92 | $this->errors[] = $error; |
| 93 | } |
| 94 | } |
| 95 |