2

我在灯塔中定义了一个查询:

extend type Query {
    products(input: ListInput @spread): [Product]
        @field(resolver: "App\\GraphQL\\Queries\\BusinessInformation\\ProductComplex@index")
}

但结果products没有分页。我不能同时使用两者@field@paginate因为应该只有一个解析器。如何使用自定义解析器对雄辩的查询进行分页?

我已经搜索并发现我builder可以使用,但是当我定义了适当的模型时,我不想使用查询构建器。

4

2 回答 2

2

我设法找到了解决方案:

extend type Query {
    products(captionId: ID, subFieldId: ID, q: String): [Product]
    @paginate(type: "paginator" defaultCount: 10 maxCount: 100
        builder: "App\\GraphQL\\Queries\\CustomerManagement\\TariffBook\\ProductComplex@index")
}

只是需要使用builderinsidepaginate指令。

于 2020-08-23T06:41:43.333 回答
0

只需将分页添加到您的查询中$posts = DB::table('posts')->paginate(12);

此外,在这里你会找到几个解决这个问题的方法: How to use pagination with laravel DB::select query

欢呼。

于 2020-08-03T06:15:57.737 回答