|
6 | 6 |
|
7 | 7 | use GraphQL\Executor\ExecutionResult; |
8 | 8 | use GraphQL\Executor\Promise\PromiseAdapter; |
| 9 | +use GraphQL\GraphQL; |
9 | 10 | use GraphQL\Type\Schema; |
10 | 11 | use GraphQL\Validator\DocumentValidator; |
11 | 12 | use GraphQL\Validator\Rules\DisableIntrospection; |
@@ -34,16 +35,20 @@ class Executor |
34 | 35 |
|
35 | 36 | private $defaultFieldResolver; |
36 | 37 |
|
| 38 | + private $useExperimentalExecutor; |
| 39 | + |
37 | 40 | public function __construct( |
38 | 41 | ExecutorInterface $executor, |
39 | 42 | PromiseAdapter $promiseAdapter, |
40 | 43 | EventDispatcherInterface $dispatcher, |
41 | | - ?callable $defaultFieldResolver = null |
| 44 | + ?callable $defaultFieldResolver = null, |
| 45 | + bool $useExperimental = false |
42 | 46 | ) { |
43 | 47 | $this->executor = $executor; |
44 | 48 | $this->promiseAdapter = $promiseAdapter; |
45 | 49 | $this->dispatcher = $dispatcher; |
46 | 50 | $this->defaultFieldResolver = $defaultFieldResolver; |
| 51 | + $this->useExperimentalExecutor = $useExperimental; |
47 | 52 | } |
48 | 53 |
|
49 | 54 | public function setExecutor(ExecutorInterface $executor): self |
@@ -122,6 +127,8 @@ public function disableIntrospectionQuery(): void |
122 | 127 | */ |
123 | 128 | public function execute(?string $schemaName, array $request, $rootValue = null): ExecutionResult |
124 | 129 | { |
| 130 | + $this->useExperimentalExecutor ? GraphQL::useExperimentalExecutor() : GraphQL::useReferenceExecutor(); |
| 131 | + |
125 | 132 | $executorArgumentsEvent = $this->preExecute( |
126 | 133 | $this->getSchema($schemaName), |
127 | 134 | $request[ParserInterface::PARAM_QUERY] ?? null, |
|
0 commit comments