我正在尝试进行查询,可以在其中添加具有多个选项的过滤器。我目前有这个查询
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] } }
]
但是我无法执行它们。我需要以这种方式修改此查询的帮助。
在查询中,您需要指定由Hasura自动生成的正确类型。在Hasura控制台的GraphiQL选项卡中,有一个文档浏览器选项卡。在那里,您可以看到Hasura为每个查询生成的类型。
您将需要在Hasura控制台中签入,但查询应类似于:
query FacilitiesQuery(
$limit: Int
$offset: Int
$where: facilities_bool_exp!
$sort: [facilities_order_by!]
) {
facilities(
limit: $limit
offset: $offset
where: $where
}
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
}
}
}
您可以根据需要在哪里构建。