Skip to content

Commit c18cd16

Browse files
committed
GraphQL\Server: set PromiseAdapter before executing query
1 parent d10e933 commit c18cd16

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Server.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use GraphQL\Error\Error;
55
use GraphQL\Error\InvariantViolation;
66
use GraphQL\Executor\ExecutionResult;
7+
use GraphQL\Executor\Executor;
78
use GraphQL\Executor\Promise\PromiseAdapter;
89
use GraphQL\Language\AST\DocumentNode;
910
use GraphQL\Language\Parser;
@@ -482,6 +483,12 @@ public function executeQuery($query, array $variables = null, $operationName = n
482483
});
483484
}
484485

486+
if ($this->promiseAdapter) {
487+
// TODO: inline GraphQL::executeAndReturnResult and pass promise adapter to executor constructor directly
488+
$promiseAdapter = Executor::getPromiseAdapter();
489+
Executor::setPromiseAdapter($this->promiseAdapter);
490+
}
491+
485492
$result = GraphQL::executeAndReturnResult(
486493
$this->getSchema(),
487494
$query,
@@ -491,6 +498,10 @@ public function executeQuery($query, array $variables = null, $operationName = n
491498
$operationName
492499
);
493500

501+
if (isset($promiseAdapter)) {
502+
Executor::setPromiseAdapter($promiseAdapter);
503+
}
504+
494505
// Add details about original exception in error entry (if any)
495506
if ($this->debug & static::DEBUG_EXCEPTIONS) {
496507
$result->setErrorFormatter([$this, 'formatError']);

0 commit comments

Comments
 (0)