ra-data-hasura-graphql
ra-data-hasura-graphql copied to clipboard
Is it possible to filter on nested attributes?
Similar to sort, but for filters: https://github.com/Steams/ra-data-hasura-graphql#sorting
Any luck with this?
0.1.12 has undocumented hasura-raw-query
-feature, which allows injecting "raw" hasura filters and therefore filtering using relations (nested attributes):
filter: {
MyRelation: {
format: "hasura-raw-query",
value: {
relation_field: { _eq: my_value },
},
},
}
What is MyRelation in here?
Can you equivalent of below?
query MyQuery {
onboardings(order_by: {sort_order: asc}, where: {language: {code: {_eq: "en"}}}) {
description
image
}
}
I'd guess
filter: {
language: {
format: "hasura-raw-query",
value: {
code: { _eq: "en" },
},
},
}
Ok. Will it work for useQuery?
const { data, loading, error } = useQuery({
type: 'getList',
resource: 'onboardings',
payload: { filter: {format: "hasura-raw-query" , id: { '_eq' : 26}}}
});
It seems like it would be relatively straight-forward to add a simple syntax to the filter strings e.g. passing "author.name@_ilike" as a source and then create the right nested filter structure in the generated variables. In the case of the example above:
{ where: { author: { name: _eq: some_value}}}
If this doesn't get implemented into the core you could create a custom variable generator that overwrite the standard filters.
@tylermorganme ~ this repository is now depreciated. The Hasura organization has adopted and now maintains this library. Going forward, you can use this: https://github.com/hasura/ra-data-hasura