Skip to content

Commit

Permalink
GraphQL\Server: set PromiseAdapter before executing query
Browse files Browse the repository at this point in the history
  • Loading branch information
vladar committed Jan 26, 2017
1 parent d10e933 commit c18cd16
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Executor\ExecutionResult;
use GraphQL\Executor\Executor;
use GraphQL\Executor\Promise\PromiseAdapter;
use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\Parser;
Expand Down Expand Up @@ -482,6 +483,12 @@ public function executeQuery($query, array $variables = null, $operationName = n
});
}

if ($this->promiseAdapter) {
// TODO: inline GraphQL::executeAndReturnResult and pass promise adapter to executor constructor directly
$promiseAdapter = Executor::getPromiseAdapter();
Executor::setPromiseAdapter($this->promiseAdapter);
}

$result = GraphQL::executeAndReturnResult(
$this->getSchema(),
$query,
Expand All @@ -491,6 +498,10 @@ public function executeQuery($query, array $variables = null, $operationName = n
$operationName
);

if (isset($promiseAdapter)) {
Executor::setPromiseAdapter($promiseAdapter);
}

// Add details about original exception in error entry (if any)
if ($this->debug & static::DEBUG_EXCEPTIONS) {
$result->setErrorFormatter([$this, 'formatError']);
Expand Down

0 comments on commit c18cd16

Please sign in to comment.