使用数字而不是光标分页

Pagination using numbers instead of cursor

我正在使用带有最新版本 api 平台的 Symfony 5。 运行 PHP 7.3.

我正在使用 graphql api 并尝试实现基于数字的分页。 在 current documentation 中仅解释了基于游标的分页。或者有没有办法根据光标像 [1][2][3][4][5] 这样分页?据我所知不是。

我还阅读了 ApiPlatform\Core\DataProvider\Pagination class 并研究了 getOffsetgetLimit 函数。所以我在查询中尝试传递数值,但结果是 "Cursor 0 is invalid".

查询:

`before: "0", after: "10"`
query SearchOrders($first: Int!) {
  orders(first: $first, before: "1", after: "10") {
    ...
  }
}

您需要使用 API 平台的 master 版本(或等待新版本)。 里面添加了分页。

有关文档,请参阅 https://api-platform.com/docs/master/core/graphql/#using-the-page-based-pagination