vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.81k stars 1.04k forks source link

Cannot filter collections on custom fields #2317

Open gdarchen opened 1 year ago

gdarchen commented 1 year ago

Describe the bug We would like to filter collections on a custom field.

But in the ListQueryOptions<Collection> type, in the filter parameter, we can only filter on PrimitiveFields<Collection>, and there is no way to filter on that custom field.

To Reproduce Steps to reproduce the behavior:

  1. Create a custom field
    {
      name: 'custom_field_name',
      label: [
        {
          languageCode: LanguageCode.fr,
          value: 'Custom field name',
        },
      ],
      defaultValue: false,
      type: 'boolean',
    },
  2. Generate the types
  3. Try to query on the collections with that custom field (cf. screenshot)

image

Expected behavior We would like to be able to filter on custom fields the same way we do for primitive types (such as slug, etc.).

Environment (please complete the following information):

Additional context Add any other context about the problem here.

michaelbromley commented 1 year ago

Hi,

are you able to reproduce this on a fresh installation? I can't reproduce locally (on master)

gdarchen commented 1 year ago

Hi @michaelbromley 👋 I was able to reproduce it on gdarchen/real-world-vendure (chore/filter-on-custom-field branch), especially in this commit.

I just added a custom field, generated the migration for it and the types. Then, in the product-review-admin.resolver.ts file, I try to call the findAll method of the CollectionService with a filter on the added custom field, and I have the following error:

image

We might not filter correctly 🤷