refine
                                
                                 refine copied to clipboard
                                
                                    refine copied to clipboard
                            
                            
                            
                        [BUG] Strapi v4 data provider does not working with nested filters $or and $and operator
Describe the bug
Steps To Reproduce
import { generateFilter } from "@refinedev/strapi-v4";
const filters = [
  {
    operator: "or",
    value: [
      {
        field: "affect_global",
        operator: "eq",
        value: true,
      },
      {
        operator: "and",
        value: [
          {
            field: "studio.id",
            operator: "eq",
            value: 2,
          },
          {
            field: "is_primary",
            operator: "eq",
            value: true,
          },
        ],
      },
    ],
  },
];
const query = generateFilter(filters);
Expected behavior
filters[$or][0][affect_global][$eq]=true&filters[$or][1][$and][0][studio][id][$eq]=2&filters[$or][1][$and][1][is_primary][$eq]=true
Screenshot
No response
Desktop
No response
Mobile
No response
Additional Context
No response
Hello @htdangkhoa thanks for the report. It could be an issue, can you confirm that expected filter example works with Strapi v4?
We are open to contributions for this one.
Hi @BatuhanW, I confirm that the expected filter example I gave above is working properly on Strapi v4
Hey @BatuhanW, I have been working on this. I found out that other contributor had not handled the case when the value of conditional filter could be another conditional filter. So the only way I could think of solving was recursively parsing the filters. However I am having trouble with parse and stringify from "qs" library.
My recursive approach yields expected result of @htdangkhoa, but those functions from "qs" seem to add multiple square braces where not needed.
Here is the screenshot of a new test I added in jest that handles the issue that @htdangkhoa had.
Hey @vidurkhanal could you try with query-string import? If you create a PR, we can also continue the discussion there, thanks!