在graphql中,对同一属性上的多个值进行筛选并分页
我有以下需要:使用graphql语法,根据同一属性上的多个值过滤集合,并对结果进行分页 考虑到以下实体在graphql中,对同一属性上的多个值进行筛选并分页,graphql,api-platform.com,Graphql,Api Platform.com,我有以下需要:使用graphql语法,根据同一属性上的多个值过滤集合,并对结果进行分页 考虑到以下实体 /** ... APIResource annotations */ class RssFeed { /** ... APIProperty annotations */ private $category; /** ... APIProperty annotations */ private $url; // ... gette
/** ... APIResource annotations
*/
class RssFeed {
/** ... APIProperty annotations
*/
private $category;
/** ... APIProperty annotations
*/
private $url;
// ... getters
// ... setters
}
我想过滤RssFeed
的集合,其中category
属性是“CategoryA”或“CategoryB”,并对结果进行分页
据我所知,graphql不允许编写与
rssfeed(category: ["CategoryA","CategoryB"])
{
edges { node {
url,
category
} }
}
因此,我需要使用不同的graphql查询(在正文中)来分离搜索操作,如
但是,我无法对全球结果进行分页
那么,我的问题是,有什么解决方案可以对多个值进行过滤和分页吗?我不确定这种混淆是从哪里来的,但是没有什么可以阻止您进行第一个示例,您只需要将类别输入的类型设置为字符串数组。虽然我个人将其重命名为
类别
:
type Query {
rssFeed(
first: Int,
last: Int,
before: String,
after: String,
categories: [String!]
): SomeConnection
}
您将如何实际实现解析器逻辑以使其工作取决于您,但这可能与您对单个类别的实现方式略有不同因为我无法修改我的实体,我需要创建一个自定义api平台过滤器?
type Query {
rssFeed(
first: Int,
last: Int,
before: String,
after: String,
categories: [String!]
): SomeConnection
}