We're trying to use blocks to apply filter config to collection items.
I have a block defined like so:
const CategoryFilterBlock: Block = {
slug: "CategoryFilter",
fields: [
{
name: "categoryFilterType",
label: "Type",
type: "radio",
options: ["whitelist", "blacklist"],
defaultValue: "whitelist",
},
{
name: "categories",
type: "relationship",
relationTo: Categories.slug,
hasMany: true,
},
],
};
Which is used on the collection like so:
{
<collection_config>,
{
name: "filters",
type: "blocks",
blocks: [CategoryFilterBlock],
}
}
I can query the
blockType
field and the
categoryFilterType
field, but I can't query for a value in the relationship:
// Works
{
"filters.blockType": {
equals: "CategoryFilter"
}
}
// Also works
{
"filters.categoryFilterType": {
equals: "whitelist"
}
}
// Doesnt work
{
"filters.categories.label": {
equals: "Some category label"
}
}
Is this a bug or is this just outright not possible?
Currently not possible I think. Extending the GraphQL capabilities of the API is a planned part of the roadmap
Should have mentioned this is with REST queries not GraphQL
Hey @itsjxck are you still looking for help here?
I don't know if this is still an issue or not as we parked the changes in favour of other work. I will retry and report back, but my assumption would be that it is probably fixed now
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.