【问题标题】:What is the recommended way to paginate using SPQR?使用 SPQR 进行分页的推荐方法是什么?
【发布时间】:2019-04-05 10:13:55
【问题描述】:

使用 SQPR 构建 graphQL API。我有大量数据集合,想逐页加载数据。使用 SQPR 执行此操作的推荐方法是什么?从客户端(查询)看起来如何?

另外,请记住 Apollo 客户端作为 Angular 的潜在客户端库。现在用 graphiql 进行测试。

【问题讨论】:

    标签: java graphql apollo graphiql graphql-spqr


    【解决方案1】:

    最终使用了这个

    @GraphQLQuery(name = "projects", description = "Return a paginated Projects results")
    public List<Project> getAll(
            @GraphQLArgument(name = "offset",defaultValue = "0", description = "Offset item from beginning of data") int offset,
            @GraphQLArgument(name = "limit", defaultValue = "10", description = "Limit the size of fetched results") int limit
    ) { ... }
    

    如果有人可以评论或添加不同的解决方案...

    G.

    【讨论】:

    • 您的方法非常好。有关分页和 SPQR 助手的更多一般性想法,请参阅我的回答 here。特别是如果您有兴趣支持 Connection 规范。
    猜你喜欢
    • 1970-01-01
    • 2023-02-21
    • 2020-04-20
    • 2019-09-15
    • 1970-01-01
    • 2010-10-09
    • 1970-01-01
    • 2021-11-16
    • 2012-12-20
    相关资源
    最近更新 更多