From f7dbb31461bffdee39b9e22b9d2d62fa265f6cb2 Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Fri, 18 Aug 2017 18:30:23 +0200 Subject: [PATCH 1/2] Fix nested loader using webonyx adapter --- composer.json | 2 +- .../src/PromiseAdapterInterface.php | 100 +++++++++--------- lib/promise-adapter/tests/AdapterTest.php | 1 - .../Webonyx/GraphQL/SyncPromiseAdapter.php | 18 +--- 4 files changed, 56 insertions(+), 65 deletions(-) diff --git a/composer.json b/composer.json index 88ca24a..a0a16ee 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "guzzlehttp/promises": "^1.3.0", "phpunit/phpunit": "^4.1|^5.1", "react/promise": "^2.5.0", - "webonyx/graphql-php": "^0.9.0" + "webonyx/graphql-php": "^0.9.14" }, "suggest": { "guzzlehttp/promises": "To use with Guzzle promise", diff --git a/lib/promise-adapter/src/PromiseAdapterInterface.php b/lib/promise-adapter/src/PromiseAdapterInterface.php index 6517a9e..ea28744 100644 --- a/lib/promise-adapter/src/PromiseAdapterInterface.php +++ b/lib/promise-adapter/src/PromiseAdapterInterface.php @@ -22,60 +22,60 @@ interface PromiseAdapterInterface * * @return mixed a Promise */ - public function create(&$resolve = null, &$reject = null, callable $canceller = null); + public function create(&$resolve = null, &$reject = null, callable $canceller = null); - /** - * Creates a full filed Promise for a value if the value is not a promise. - * - * @param mixed $promiseOrValue - * - * @return mixed a full filed Promise - */ - public function createFulfilled($promiseOrValue = null); + /** + * Creates a full filed Promise for a value if the value is not a promise. + * + * @param mixed $promiseOrValue + * + * @return mixed a full filed Promise + */ + public function createFulfilled($promiseOrValue = null); - /** - * Creates a rejected promise for a reason if the reason is not a promise. If - * the provided reason is a promise, then it is returned as-is. - * - * @param mixed $reason - * - * @return mixed a rejected promise - */ - public function createRejected($reason); + /** + * Creates a rejected promise for a reason if the reason is not a promise. If + * the provided reason is a promise, then it is returned as-is. + * + * @param mixed $reason + * + * @return mixed a rejected promise + */ + public function createRejected($reason); - /** - * Given an array of promises, return a promise that is fulfilled when all the - * items in the array are fulfilled. - * - * @param mixed $promisesOrValues Promises or values. - * - * @return mixed a Promise - */ - public function createAll($promisesOrValues); + /** + * Given an array of promises, return a promise that is fulfilled when all the + * items in the array are fulfilled. + * + * @param mixed $promisesOrValues Promises or values. + * + * @return mixed a Promise + */ + public function createAll($promisesOrValues); - /** - * Check if value is a promise - * - * @param mixed $value - * @param bool $strict - * - * @return bool - */ - public function isPromise($value, $strict = false); + /** + * Check if value is a promise + * + * @param mixed $value + * @param bool $strict + * + * @return bool + */ + public function isPromise($value, $strict = false); - /** - * Cancel a promise - * - * @param $promise - */ - public function cancel($promise); + /** + * Cancel a promise + * + * @param $promise + */ + public function cancel($promise); - /** - * wait for Promise to complete - * @param mixed $promise - * @param bool $unwrap - * - * @return mixed - */ - public function await($promise = null, $unwrap = false); + /** + * wait for Promise to complete + * @param mixed $promise + * @param bool $unwrap + * + * @return mixed + */ + public function await($promise = null, $unwrap = false); } diff --git a/lib/promise-adapter/tests/AdapterTest.php b/lib/promise-adapter/tests/AdapterTest.php index 738d39d..a51e9e1 100644 --- a/lib/promise-adapter/tests/AdapterTest.php +++ b/lib/promise-adapter/tests/AdapterTest.php @@ -9,7 +9,6 @@ * file that was distributed with this source code. */ - namespace Overblog\PromiseAdapter\Tests; use Overblog\PromiseAdapter\Adapter\GuzzleHttpPromiseAdapter; diff --git a/src/Promise/Adapter/Webonyx/GraphQL/SyncPromiseAdapter.php b/src/Promise/Adapter/Webonyx/GraphQL/SyncPromiseAdapter.php index f817ce6..fc2f82a 100644 --- a/src/Promise/Adapter/Webonyx/GraphQL/SyncPromiseAdapter.php +++ b/src/Promise/Adapter/Webonyx/GraphQL/SyncPromiseAdapter.php @@ -11,27 +11,19 @@ namespace Overblog\DataLoader\Promise\Adapter\Webonyx\GraphQL; -use GraphQL\Deferred; -use GraphQL\Executor\Promise\Adapter\SyncPromise; use GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter as BaseSyncPromiseAdapter; use GraphQL\Executor\Promise\Promise; use Overblog\DataLoader\DataLoader; class SyncPromiseAdapter extends BaseSyncPromiseAdapter { - /** - * Synchronously wait when promise completes - * - * @param Promise $promise - * @return mixed - */ - public function wait(Promise $promise) + protected function beforeWait(Promise $promise) { DataLoader::await(); - Deferred::runQueue(); - SyncPromise::runQueue(); - DataLoader::await(); + } - return parent::wait($promise); + protected function onWait(Promise $promise) + { + DataLoader::await(); } } From b9dfaeab241a2eb0f00907e965403b8e627f0346 Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Fri, 18 Aug 2017 18:37:30 +0200 Subject: [PATCH 2/2] Fix hhvm travis build --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a03f560..81a8f42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +dist: trusty + language: php php: