Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced filtering in PaginatedList only works as long as the attributes are distinct #3267

Open
lz-jf opened this issue Dec 10, 2024 · 1 comment
Assignees
Labels
type: bug 🐛 Something isn't working @vendure/core
Milestone

Comments

@lz-jf
Copy link

lz-jf commented Dec 10, 2024

Describe the bug
Advanced filtering in PagenatedList queries does not return any items as soon as the same attribute is filtered by more than once.
The most common use case is probably filtering by facetValueId (which strangely also is available on the shop API, but that's another topic). But using it twice within a _and or _or operator leads to no results. It does work as expected in the search query but imo the provided filter on the products query should work as you would it expect it to.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a vanilla Vendure installation with the provided sample data.
  2. Run the following query on the admin API:
query Products {
    products(options: { 
        filter: { 
            _and: [
                {
                    facetValueId: {
                        eq: "34"
                    }
                }
            ]
        }
    }) {
        totalItems
        items {
            name
        }
    }
}
  1. This should return 11 items
  2. Now add a second facetValue to the filter:
query Products {
    products(options: { 
        filter: { 
            _and: [
                {
                    facetValueId: {
                        eq: "34"
                    }
                },
                {
                    facetValueId: {
                        eq: "37"
                    }
                }
            ]
        }
    }) {
        totalItems
        items {
            name
        }
    }
}
  1. No items are returned even though there are products matching both facetValues

Expected behavior
The latter query should return 2 items.

Environment (please complete the following information):

  • @vendure/core version: 3.1.0
  • Nodejs version: 20.11.0
  • Database (mysql/postgres etc): postgres

Additional context
This can be recreated in the admin-ui by filtering by facet values Category:Furniture (34) and Color:Wood (37). It works in the admin ui because here two subsequent requests are made instead of one with both facetValues.

@lz-jf lz-jf added the type: bug 🐛 Something isn't working label Dec 10, 2024
@lz-jf
Copy link
Author

lz-jf commented Dec 12, 2024

Probably related: #112

@michaelbromley michaelbromley added this to the v3.1.2 milestone Dec 30, 2024
@michaelbromley michaelbromley moved this to 📦 Backlog in Vendure OS Roadmap Dec 30, 2024
@michaelbromley michaelbromley changed the title Advanced filtering in PaganatedList only works as long as the attributes are distinct Advanced filtering in PaginatedList only works as long as the attributes are distinct Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working @vendure/core
Projects
Status: 📦 Backlog
Development

No branches or pull requests

3 participants