nested relationship field rest api request, incorrect results
Link to reproduction
No response
Describe the Bug
in a document structure where a relationship field is inside a block youre unable to filter on the relationship values.
To Reproduce
in a document structure that looks like this in a collection called "mainpages":
{
"id": "652d0963cb6c65326d040114",
"title": "test title",
"slug": "test-slug",
"pageLayout": [
{
"relCategories": [
{
"id": "652e350fa7799c0880277631",
"title": "Design",
"slug": "design",
"_status": "published",
"createdAt": "2023-10-17T07:17:35.304Z",
"updatedAt": "2023-10-23T13:25:53.190Z"
}
],
"id": "652d09383a16ac85e2daef23",
"blockType": "projectPageBlock"
}
],
"_status": "published",
"createdAt": "2023-10-16T09:58:59.477Z",
"updatedAt": "2023-10-24T07:33:44.005Z"
}
relCategories has hasMany: true
then perform a query using the 'qs' library as follows:
const query = {
and: [
{
'pageLayout.blockType': {
equals: 'projectPageBlock'
}
},
{
'pageLayout.relCategories.slug': {
equals: 'design'
}
}
]
};
const stringifiedQuery = qs.stringify(
{
where: query
},
{ addQueryPrefix: true }
);
URL: /api/mainpages${stringifiedQuery}
this yields no results, if i remove the pageLayout.relCategories.slug object part from the query it at least returns the correct documents that match the blocktype. but i cant seem to combine the query with the relationship field containing that slug. im unsure if this an error in the way im expressing the query or if its a bug.
Payload Version
2.0.11
Adapters and Plugins
No response
I'm having a similar issue, I can't query blockType or the block data. Using next-payload and postgres.