Skip to content

Navigation Menu

Sign in
Sign up

Pagination unexpected behavior #868

Unanswered
YaFou asked this question in Q&A
Discussion options

I use the paginator but I have some unexpected results on the page info.
I received this following response:

"pageInfo": {
 "hasNextPage": false,
 "hasPreviousPage": false,
 "startCursor": "YXJyYXljb25uZWN0aW9uOjEw",
 "endCursor": "YXJyYXljb25uZWN0aW9uOjE4"
}

However, I have more than 10 elements (which is the default limit I've set) and the hasNextPage is set to false instead of true.


Here is my resolver:

<?php
namespace App\Application\GraphQL\Resolver;
use App\Domain\Account\Entity\Owner;
use App\Domain\Account\Repository\AccountRepository;
use Overblog\GraphQLBundle\Definition\Argument;
use Overblog\GraphQLBundle\Relay\Connection\ConnectionInterface;
class OwnerAccountsResolver extends AbstractResolver
{
 use ConnectionHelper;
 public function __construct(private AccountRepository $repository)
 {
 }
 protected static function getResolverName(): string
 {
 return 'owner:accounts';
 }
 public function resolve(Owner $owner, Argument $argument): ConnectionInterface
 {
 $paginator = new Paginator(fn(int $offset, ?int $limit) => $this->repository->findFromOwner($owner, $offset, $limit ?? 10));
 return $paginator->auto($argument, $this->repository->countFromOwner($owner));
 }
}

Tell me if I did something wrong, thank you!

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /