refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
25.95k stars 1.96k forks source link

[BUG] Cannot specify `0` as filter value in the Nestjs-Query Data Provider #6022

Open yamadayutaka opened 3 weeks ago

yamadayutaka commented 3 weeks ago

Describe the bug

Cannot specify 0 as filter value. Also, "" cannot be specified.

Because it is excluded by the conditions in the following sections.

https://github.com/refinedev/refine/blob/a8404fc92c856f89b06684de6ad481aa840267be/packages/nestjs-query/src/utils/index.ts#L165

Steps To Reproduce

  1. create Nestjs-Query example project.
pnpm create refine-app@latest --example data-provider-nestjs-query
  1. implement initial filter with a value of 0 on src/pages/categories/list.tsx.
  const { tableProps, sorters } = useTable<ICategory>({
    initialSorter: [
      {
        field: "id",
        order: "asc",
      },
    ],
    filters: {
      initial: [
        {
          field: 'id',
          operator: 'eq',
          value: 0 
        }
      ],
    },
  1. run refine app.
pnpm dev
  1. navigate Categories menu.

  2. GraphQL query is executed with no filter specified. (Inspect in the DevTools network panel.)

filter: {},

Expected behavior

GraphQL query is executed with the following filter.

filter: {id: {eq: 0}},

Packages

Additional Context

I have already fixed this issue and will create a PR.

alicanerdurmaz commented 3 weeks ago

Hello @yamadayutaka, thanks for the detailed explanation.

Do you want to work on this?

yamadayutaka commented 3 weeks ago

Hi @alicanerdurmaz , I have created a PR, please check it out.

BatuhanW commented 3 weeks ago

Hey @yamadayutaka thanks for the neat PR! It's all approved, we'll release it in our next release cycle.