Skip to content

Commit

Permalink
Execution: modified deferred behavior to be more predictable (+added …
Browse files Browse the repository at this point in the history
…more tests for them)
  • Loading branch information
vladar committed Dec 16, 2016
1 parent 9826f9a commit ff3a40d
Show file tree
Hide file tree
Showing 6 changed files with 500 additions and 18 deletions.
3 changes: 1 addition & 2 deletions docs/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ Here is an example of `BlogStory` resolver for field `author` that uses deferrin
MyUserBuffer::add($blogStory['authorId']);

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

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

To integrate other platform - implement `GraphQL\Executor\Promise\PromiseAdapter` interface.
9 changes: 0 additions & 9 deletions src/Executor/Promise/Adapter/SyncPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ public static function runQueue()
}
}

public static function runNext()
{
$q = self::$queue;
if ($q && !$q->isEmpty()) {
$task = $q->dequeue();
$task();
}
}

public $state = self::PENDING;

public $result;
Expand Down
2 changes: 1 addition & 1 deletion src/Executor/Promise/Adapter/SyncPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function wait(Promise $promise)
!($dfdQueue->isEmpty() && $promiseQueue->isEmpty())
) {
Deferred::runQueue();
SyncPromise::runNext();
SyncPromise::runQueue();
}

/** @var SyncPromise $syncPromise */
Expand Down

0 comments on commit ff3a40d

Please sign in to comment.