Skip to content

Commit ff3a40d

Browse files
committed
Execution: modified deferred behavior to be more predictable (+added more tests for them)
1 parent 9826f9a commit ff3a40d

File tree

6 files changed

+500
-18
lines changed

6 files changed

+500
-18
lines changed

docs/data-fetching.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Here is an example of `BlogStory` resolver for field `author` that uses deferrin
180180
MyUserBuffer::add($blogStory['authorId']);
181181

182182
return new GraphQL\Deferred(function () use ($blogStory) {
183-
MyUserBuffer::loadOnce();
183+
MyUserBuffer::loadBuffered();
184184
return MyUserBuffer::get($blogStory['authorId']);
185185
});
186186
}
@@ -242,6 +242,5 @@ Platforms supported out of the box:
242242

243243
* [ReactPHP](https://github.com/reactphp/react) (requires **react/promise** as composer dependency):
244244
`GraphQL\GraphQL::setPromiseAdapter(new GraphQL\Executor\Promise\Adapter\ReactPromiseAdapter());`
245-
* HHVM: TODO
246245

247246
To integrate other platform - implement `GraphQL\Executor\Promise\PromiseAdapter` interface.

src/Executor/Promise/Adapter/SyncPromise.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ public static function runQueue()
3636
}
3737
}
3838

39-
public static function runNext()
40-
{
41-
$q = self::$queue;
42-
if ($q && !$q->isEmpty()) {
43-
$task = $q->dequeue();
44-
$task();
45-
}
46-
}
47-
4839
public $state = self::PENDING;
4940

5041
public $result;

src/Executor/Promise/Adapter/SyncPromiseAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function wait(Promise $promise)
133133
!($dfdQueue->isEmpty() && $promiseQueue->isEmpty())
134134
) {
135135
Deferred::runQueue();
136-
SyncPromise::runNext();
136+
SyncPromise::runQueue();
137137
}
138138

139139
/** @var SyncPromise $syncPromise */

0 commit comments

Comments
 (0)