[FEAT] Allow StrapiV4 CRUDFilters to do deep filter
See original GitHub issueIs your feature request related to a problem? Please describe. On Strapi, you can use objects to make deep filters (https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#deep-filtering) Example:
filters: {
chef: {
restaurants: {
stars: {
$eq: 5,
},
},
},
},
GET /api/restaurants?filters[chef][restaurants][stars][$eq]=5
Refine, only allows arrays, with logical filters or conditional filters (https://refine.dev/docs/guides-and-concepts/data-provider/handling-filters/): Example:
const filter = [
{
field: "name",
operator: "eq",
value: "John",
},
If I try to use a relation field as a filter, strapi will throw an error.
Describe the solution you’d like I´d like to use deep filters so I can filter some relational tables. On my real case, I´m doing a todo list for each project. I also need to filter this todo list based on its procedure, on another component, and I need to mutate it too. Doing this filtering makes easier on the code logic.
Describe alternatives you’ve considered I can cheat the URL constructor doing this:
const filter = [
{
field: "chef[restaurants][stars",
operator: "eq",
value: "John",
},
It converts to this: /api/restaurants?filters[chef][restaurants][stars][$eq]=5 It works!
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top GitHub Comments
@aliemir
Hello, can we do something like:
And its must works only in Sptrapi provider. This solution not implements “dirty” logic in core.
p.s. Dot separated like in Laravel.
Hey, We’ve released @pankod/refine-strapi-v4@3.39.2. Thank you @npanti @rollsover 🎉