question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEAT] Allow StrapiV4 CRUDFilters to do deep filter

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
rollsovercommented, Dec 6, 2022

@aliemir

Hello, can we do something like:

{
    field: "chef.restaurants.stars",
    operator: "eq",
    value: 5,
}

And its must works only in Sptrapi provider. This solution not implements “dirty” logic in core.

p.s. Dot separated like in Laravel.

0reactions
omeraplakcommented, Dec 12, 2022

Hey, We’ve released @pankod/refine-strapi-v4@3.39.2. Thank you @npanti @rollsover 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Filter Results on Deeply Nested fields in Strapi
This article will be covering the different ways to filter results using the following APIs: Rest API,; Entity Service API,; Query Engine API, ......
Read more >
Handling Filters - Refine Dev
refine expects an array of type CrudFilters to filter results based on some field's values. So you can use more than one filter....
Read more >
The ability to deep filter on component objects in GraphQL ...
One-to-many relations have the ability to set a query for a nested field. Components however, do not. If I've missed any possible solution ......
Read more >
Filters | Strapi Documentation
Querying your API with deep filters may cause performance issues. If one of your deep filtering queries is too slow, we recommend building...
Read more >
Announcing strapi@3.0.0-alpha.26 — Filter on deeply nested ...
For now, let's see what's new in this release! Filtering on deeply nested objects. First up, deep filtering. Did you ever want to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found