-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pagination helper - backward count does not work with promises #286
Comments
Try this please: $paginator = new Paginator(function($offset, $limit) {
return $this->someLoader->load(new SomeKey($criteria, $offset, $limit))->then(function(array $ids) {
return $this->someOtherLoader->loadMany($ids);
});
}, Paginator::MODE_PROMISE); |
Sorry, I did it already, forgot to add it to the sample code. Otherwise it would not work with forward too. Also note: the note is raised after the $count callback invokation, not the paginator callback. So the issue is the promise returned from $count: $paginator->auto($args, function() {
return $this->someLoader->load(new SomeKey($criteria))->then(FnUtils::arrayLikeCount());
});
|
I think the reason, why the notice does not trigger in case of forward is because it is not accessed there, while the backward does access the Connection::$totalCount and therefore triggers the error. So probably the issue is in general, that the $count callback in Paginator is not supporting promise itself? |
Paginator $count callback does work with promise when using forward, but not backward. In case of backward, you get:
Object of class GraphQL\\Executor\\Promise\\Promise could not be converted to int
Example code:
The text was updated successfully, but these errors were encountered: