Hey all,
I’m working with a Collection: Persons that has a relationship with Locations (fields: name, slug (which is unique)). On the frontend, I’m trying to use a Query (useAllPersonsQuery) to filter persons by a specific location slug, like this:
const { data, loading, error, fetchMore } = useAllPersonsQuery({
variables: {
where: {
'locations.slug': {
in: ['berlin'],
},
},
},
});However, I’m getting the following error:
Object literal may only specify known properties, and 'locations.slug' does not exist in type 'Person_Where'.
This makes perfect sense since the
Person_Wheretype only has
locationsand not
locations.slug. So, filtering by locations using IDs, like so, works:
locations: {
in: ['66eac7cf765d57eb0238e664'],
}Is There a Way to Filter by a Different Field than ID (e.g., Slug) in a Where Query?
This is a known limitation of our GraphQL implementation as of right now. There is a GitHub discussion out there if you search for it in our repo.
Star
Discord
online
Get dedicated engineering support directly from the Payload team.