Graphqlbundle: Asking Question

Created on 13 Sep 2018  路  6Comments  路  Source: overblog/GraphQLBundle

Hi is it possible to use pagerfanta pagination on Relay Pagination helper?

question

Most helpful comment

Are Yoh Kenn?

All 6 comments

The doc example does not help? What do you exactly missing?

The doc example does not help? What do you exactly missing?

in pagerfanta you need page number and limit, paginator helper callback function has offset and limit when i try to dump limit it automatically increment, for example when i put argument "first: 10" then on callback it become 11, hope you can help me. below is my sample code:

query { provinces(first: 10){ edges{ node{ proNo proName } cursor } pageInfo{ hasNextPage hasPreviousPage startCursor endCursor } totalCount } }

`
$paginator = new Paginator(function ($offset, $limit) use ($args) {
$filters = $args['filters'] ?? array();
$orders = $args['orders'] ?? array();
$numItems = $limit;
$page = ceil(($offset + 1) / $limit);
$pagerfanta = $this->provinceRepository->getPaginatedProvinces($args, $page, $numItems);

        $provinces = [];
        foreach($pagerfanta->getCurrentPageResults() as $result){
               $provinces[] = $result;
        }

        return $provinces;
    });

    return array('provinces' => $paginator->auto($args, function() {
        $totalCount = $this->provinceRepository->createQueryBuilder('p')
            ->select('COUNT(p.proCode)')
            ->getQuery()
            ->getSingleScalarResult();

        return $totalCount;
    }));

`

Are Yoh Kenn?

@nckenn the relay paginator works a way difference from a normal paginator. This was created by Facebook for it own use in a first place. This paginator is more like an infinite scroll... If you need some thing more regular maybe you should implement your own logic.

@nckenn the relay paginator works a way difference from a normal paginator. This was created by Facebook for it own use in a first place. This paginator is more like an infinite scroll... If you need some thing more regular maybe you should implement your own logic.

@nckenn the relay paginator works a way difference from a normal paginator. This was created by Facebook for it own use in a first place. This paginator is more like an infinite scroll... If you need some thing more regular maybe you should implement your own logic.

thanks ;)

I'm closing this, don't hesitate to continue discussion if needed :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rpander93 picture rpander93  路  3Comments

Vincz picture Vincz  路  3Comments

VincentClair picture VincentClair  路  5Comments

paoloposo picture paoloposo  路  3Comments

ooflorent picture ooflorent  路  6Comments