Skip to content

Commit 4983227

Browse files
authored
Merge pull request #16 from mcg-web/fix-nested-loader-using-webonyx-adapter
Fix nested loaders using webonyx adapter
2 parents fa8286f + b9dfaea commit 4983227

File tree

5 files changed

+58
-65
lines changed

5 files changed

+58
-65
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dist: trusty
2+
13
language: php
24

35
php:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"guzzlehttp/promises": "^1.3.0",
3434
"phpunit/phpunit": "^4.1|^5.1",
3535
"react/promise": "^2.5.0",
36-
"webonyx/graphql-php": "^0.9.0"
36+
"webonyx/graphql-php": "^0.9.14"
3737
},
3838
"suggest": {
3939
"guzzlehttp/promises": "To use with Guzzle promise",

lib/promise-adapter/src/PromiseAdapterInterface.php

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,60 @@ interface PromiseAdapterInterface
2222
*
2323
* @return mixed a Promise
2424
*/
25-
public function create(&$resolve = null, &$reject = null, callable $canceller = null);
25+
public function create(&$resolve = null, &$reject = null, callable $canceller = null);
2626

27-
/**
28-
* Creates a full filed Promise for a value if the value is not a promise.
29-
*
30-
* @param mixed $promiseOrValue
31-
*
32-
* @return mixed a full filed Promise
33-
*/
34-
public function createFulfilled($promiseOrValue = null);
27+
/**
28+
* Creates a full filed Promise for a value if the value is not a promise.
29+
*
30+
* @param mixed $promiseOrValue
31+
*
32+
* @return mixed a full filed Promise
33+
*/
34+
public function createFulfilled($promiseOrValue = null);
3535

36-
/**
37-
* Creates a rejected promise for a reason if the reason is not a promise. If
38-
* the provided reason is a promise, then it is returned as-is.
39-
*
40-
* @param mixed $reason
41-
*
42-
* @return mixed a rejected promise
43-
*/
44-
public function createRejected($reason);
36+
/**
37+
* Creates a rejected promise for a reason if the reason is not a promise. If
38+
* the provided reason is a promise, then it is returned as-is.
39+
*
40+
* @param mixed $reason
41+
*
42+
* @return mixed a rejected promise
43+
*/
44+
public function createRejected($reason);
4545

46-
/**
47-
* Given an array of promises, return a promise that is fulfilled when all the
48-
* items in the array are fulfilled.
49-
*
50-
* @param mixed $promisesOrValues Promises or values.
51-
*
52-
* @return mixed a Promise
53-
*/
54-
public function createAll($promisesOrValues);
46+
/**
47+
* Given an array of promises, return a promise that is fulfilled when all the
48+
* items in the array are fulfilled.
49+
*
50+
* @param mixed $promisesOrValues Promises or values.
51+
*
52+
* @return mixed a Promise
53+
*/
54+
public function createAll($promisesOrValues);
5555

56-
/**
57-
* Check if value is a promise
58-
*
59-
* @param mixed $value
60-
* @param bool $strict
61-
*
62-
* @return bool
63-
*/
64-
public function isPromise($value, $strict = false);
56+
/**
57+
* Check if value is a promise
58+
*
59+
* @param mixed $value
60+
* @param bool $strict
61+
*
62+
* @return bool
63+
*/
64+
public function isPromise($value, $strict = false);
6565

66-
/**
67-
* Cancel a promise
68-
*
69-
* @param $promise
70-
*/
71-
public function cancel($promise);
66+
/**
67+
* Cancel a promise
68+
*
69+
* @param $promise
70+
*/
71+
public function cancel($promise);
7272

73-
/**
74-
* wait for Promise to complete
75-
* @param mixed $promise
76-
* @param bool $unwrap
77-
*
78-
* @return mixed
79-
*/
80-
public function await($promise = null, $unwrap = false);
73+
/**
74+
* wait for Promise to complete
75+
* @param mixed $promise
76+
* @param bool $unwrap
77+
*
78+
* @return mixed
79+
*/
80+
public function await($promise = null, $unwrap = false);
8181
}

lib/promise-adapter/tests/AdapterTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
1312
namespace Overblog\PromiseAdapter\Tests;
1413

1514
use Overblog\PromiseAdapter\Adapter\GuzzleHttpPromiseAdapter;

src/Promise/Adapter/Webonyx/GraphQL/SyncPromiseAdapter.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,19 @@
1111

1212
namespace Overblog\DataLoader\Promise\Adapter\Webonyx\GraphQL;
1313

14-
use GraphQL\Deferred;
15-
use GraphQL\Executor\Promise\Adapter\SyncPromise;
1614
use GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter as BaseSyncPromiseAdapter;
1715
use GraphQL\Executor\Promise\Promise;
1816
use Overblog\DataLoader\DataLoader;
1917

2018
class SyncPromiseAdapter extends BaseSyncPromiseAdapter
2119
{
22-
/**
23-
* Synchronously wait when promise completes
24-
*
25-
* @param Promise $promise
26-
* @return mixed
27-
*/
28-
public function wait(Promise $promise)
20+
protected function beforeWait(Promise $promise)
2921
{
3022
DataLoader::await();
31-
Deferred::runQueue();
32-
SyncPromise::runQueue();
33-
DataLoader::await();
23+
}
3424

35-
return parent::wait($promise);
25+
protected function onWait(Promise $promise)
26+
{
27+
DataLoader::await();
3628
}
3729
}

0 commit comments

Comments
 (0)