Skip to content

Support offset/slice in pagination #4672

@tacman

Description

@tacman

Description

I would like to use API Platform to get a slice of the results, not a page.

Example

/api/...?offset=422&items_per_page=81

A javascript library I'm using for infinite scrolling fetches more than a "page". Currently within API Platform, the offset is calculated from the page and returned, I'd like to override what's returned.

        $firstResult = ($page - 1) * $itemsPerPage;
// ...
       return [$firstResult, $itemsPerPage];

I considered extending the Doctrine ORM paginator class, but it's marked as final.

There's probably an elegant solution here somewhere, but I can't find it, so maybe it can be added. What I want is identical to the Doctrine ORM provider with pagination, so ideally I'd like to leverage the existing code and simply change the first result offset.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions