【发布时间】:2020-08-12 16:59:56
【问题描述】:
我正在尝试进行查询,我可以在其中添加具有多个选项的过滤器。我目前有这个查询
query FacilitiesQuery(
$limit: Int
$offset: Int
$query: String
$sort: [facilities_order_by!]
) {
facilities(
limit: $limit
offset: $offset
where: {
_or: [
{ name: { _ilike: $query } },
{ location: { _ilike: $query } },
]
_and: [
{ deleted_at: { _is_null: true } },
{ status_id: { _eq: 1 } }
]
}
order_by: $sort
) {
id
location
name
status_id
updated_at
created_at
area
floor
handover_condition
handover_meter
handover_office
lcd
level
move_in_date
rcd
company_id
deleted_at
expiry_date
area_type
building_name
enum_area_type {
id
name
}
}
enum_facility_statuses {
id
value
}
facilities_aggregate(where: { deleted_at: { _is_null: true } }) {
aggregate {
count
}
}
}
我正在尝试通过status_id 进行查询。我正在尝试在前端实现一个过滤器,它可以根据带有复选框的模式获取所有选中的选项。
例如我想获取 status_id 为 1 和 2 的记录,我正在寻找这样的东西
_and: [
{ deleted_at: { _is_null: true } },
{ status_id: { _eq: [1,2] } }
]
但我无法执行它们。我需要帮助以这种方式修改此查询。
【问题讨论】:
-
它不仅仅是前端...... api 必须支持你的所有需求......
eq通常意味着一个值 -
我是初学者,我真的不知道如何将它添加到API中
-
我的意思是 GQL 不支持这个?如果需要,我可以修改我的查询。我只需要根据状态进行过滤。
-
GQL 标准没有定义(过滤)——它与实现相关......阅读文档......
_in设置?嵌套_or(id eq 1 或 id eq 2)
标签: reactjs graphql react-apollo hasura