【问题标题】:Pagination using numbers instead of cursor使用数字而不是光标进行分页
【发布时间】:2020-06-28 10:31:44
【问题描述】:

我正在使用 Symfony 5 和最新版本的 api-platform。运行 PHP 7.3。

我正在使用 graphql api 并尝试实现基于数字的分页。 在current documentation 中只解释了基于游标的分页。或者有没有办法根据光标进行分页,如 [1][2][3][4][5]? AFAIK 不是。

我还阅读了 ApiPlatform\Core\DataProvider\Pagination 类并研究了 getOffsetgetLimit 函数。因此,我尝试在查询中传递数值,但结果是“光标 0 无效”。

查询:

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

【问题讨论】:

    标签: php symfony graphql api-platform.com


    【解决方案1】:

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

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-09
    • 1970-01-01
    • 2021-06-02
    • 2014-03-23
    • 1970-01-01
    • 1970-01-01
    • 2015-03-12
    • 2019-01-01
    相关资源
    最近更新 更多