From 6a171efeeaf0bc3f76f9bdcd90b03d652b0ed919 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Sat, 20 Nov 2021 09:22:18 +0100 Subject: [PATCH] Check if experimental executor exists before trying to set it This allows the bundle to use the latest webonyx dev version. --- src/Request/Executor.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Request/Executor.php b/src/Request/Executor.php index ae056df0f..3909517ee 100644 --- a/src/Request/Executor.php +++ b/src/Request/Executor.php @@ -34,7 +34,7 @@ class Executor private EventDispatcherInterface $dispatcher; private PromiseAdapter $promiseAdapter; private ExecutorInterface $executor; - private bool $useExperimentalExecutor; + private bool $useExperimentalExecutor; // TODO: remove in 1.0 /** * @var callable|null @@ -46,13 +46,13 @@ public function __construct( PromiseAdapter $promiseAdapter, EventDispatcherInterface $dispatcher, ?callable $defaultFieldResolver = null, - bool $useExperimental = false + bool $useExperimental = false // TODO: remove in 1.0 ) { $this->executor = $executor; $this->promiseAdapter = $promiseAdapter; $this->dispatcher = $dispatcher; $this->defaultFieldResolver = $defaultFieldResolver; - $this->useExperimentalExecutor = $useExperimental; + $this->useExperimentalExecutor = $useExperimental; // TODO: remove in 1.0 } public function setExecutor(ExecutorInterface $executor): self @@ -133,7 +133,10 @@ public function disableIntrospectionQuery(): void */ public function execute(?string $schemaName, array $request, $rootValue = null): ExecutionResult { - $this->useExperimentalExecutor ? GraphQL::useExperimentalExecutor() : GraphQL::useReferenceExecutor(); + // TODO: remove following if-block in 1.0 + if (method_exists(GraphQL::class, 'useExperimentalExecutor')) { + $this->useExperimentalExecutor ? GraphQL::useExperimentalExecutor() : GraphQL::useReferenceExecutor(); + } $schema = $this->getSchema($schemaName); /** @var string $schemaName */