In the process of generating the REST API interface in Hasura, I expect to pass multiple parameters into the interface to complete the filtering of target data. However, the Hasura development documentation did not introduce the graphiql writing method for the REST API to receive multiple parameters. I tried passing an array to complete the task, but the interface encountered an error. I don’t know if Hasura doesn’t support it or if there is a problem with my code editing.
Just like in the screenshot, multiple fields may need to be passed in as filters, which could be one or multiple, depending on the user. What I mean is how to receive any number of parameters as filtering options.
query getFilteredAndSortedData(
$where: jsonb, # Use jsonb type to receive arbitrary filter conditions
$order_by: [order_by_item!]! # Use an array to receive multiple sorting conditions
) {
your_table_name(
where: $where, # Apply filter conditions to the query
order_by: $order_by # Apply sorting conditions to the query
) {
# Return the fields you want
id
# ... other fields
}
}