From d5e3d08d850a5d531675ad7889c0b433b65c6a56 Mon Sep 17 00:00:00 2001 From: Vladimir Razuvaev Date: Sun, 20 Aug 2017 20:09:55 +0700 Subject: [PATCH] Minor Executor tweaks --- src/Executor/Executor.php | 37 ++++++++++--------------------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/src/Executor/Executor.php b/src/Executor/Executor.php index 90362cb..f06aa73 100644 --- a/src/Executor/Executor.php +++ b/src/Executor/Executor.php @@ -85,7 +85,6 @@ class Executor * @param array|\ArrayAccess $variableValues * @param null $operationName * @param callable $fieldResolver - * @param PromiseAdapter $promiseAdapter * * @return ExecutionResult|Promise */ @@ -96,22 +95,14 @@ class Executor $contextValue = null, $variableValues = null, $operationName = null, - callable $fieldResolver = null, - PromiseAdapter $promiseAdapter = null + callable $fieldResolver = null ) { - $promiseAdapter = $promiseAdapter ?: self::getPromiseAdapter(); + // TODO: deprecate (just always use SyncAdapter here) and have `promiseToExecute()` for other cases + $promiseAdapter = self::getPromiseAdapter(); - $result = self::promiseToExecute( - $promiseAdapter, - $schema, - $ast, - $rootValue, - $contextValue, - $variableValues, - $operationName, - $fieldResolver - ); + $result = self::promiseToExecute($promiseAdapter, $schema, $ast, $rootValue, $contextValue, + $variableValues, $operationName, $fieldResolver); // Wait for promised results when using sync promises if ($promiseAdapter instanceof SyncPromiseAdapter) { @@ -122,7 +113,7 @@ class Executor } /** - * Same as executeQuery(), but requires promise adapter and returns a promise which is always + * Same as execute(), but requires promise adapter and returns a promise which is always * fulfilled with an instance of ExecutionResult and never rejected. * * Useful for async PHP platforms. @@ -150,22 +141,14 @@ class Executor ) { try { - $exeContext = self::buildExecutionContext( - $schema, - $ast, - $rootValue, - $contextValue, - $variableValues, - $operationName, - $fieldResolver, - $promiseAdapter - ); + $exeContext = self::buildExecutionContext($schema, $ast, $rootValue, $contextValue, $variableValues, + $operationName, $fieldResolver, $promiseAdapter); } catch (Error $e) { return $promiseAdapter->createFulfilled(new ExecutionResult(null, [$e])); } $executor = new self($exeContext); - return $executor->executeQuery(); + return $executor->doExecute(); } /** @@ -291,7 +274,7 @@ class Executor /** * @return Promise */ - private function executeQuery() + private function doExecute() { // Return a Promise that will eventually resolve to the data described by // The "Response" section of the GraphQL specification.