Message Boards
GraphQL filter nested fields with lambda operators
GraphQL filter nested fields with lambda operators
New Member Posts: 2 Join Date: 3/20/21 Recent PostsHi, I'm following: https://help.liferay.com/hc/en-us/articles/360039026252-Filter-Sort-and-Search, but I'm able to filter only first level fields.
I'm trying to query blogPostings adding a filter on taxonomyCategoryBriefs with taxonomyCategoryId = X, but I get "HTTP 400 Bad Request"
This is my data without filter:
{
"data": {
"blogPostings":
{
"items": [
{
"id": 38326,
"headline":
"Liferay Post",
"articleBody":
"<p>Lorem ipsum dolor sit amet, consectetur adipiscing
elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est
laborum.</p>",
"taxonomyCategoryBriefs": [
{
"taxonomyCategoryId": 38437,
"taxonomyCategoryName": "Liferay"
}
],
"image": {
"contentUrl":
"/documents/38334/38340/liferay.png/ae6992f2-c36a-03ff-89af-d6fc09112041?t=1616148845617"
}
}
]
}
}
}
This is the query with the filter:
query Category {
blogPostings(siteKey: "20121",
filter: "taxonomyCategoryBriefs/any(c: c/taxonomyCategoryName eq
38437)"
) {...}
Any idea? Or is there another method to get all posts of a category?
Thanks
RE: GraphQL filter nested fields with lambda operators
Expert Posts: 348 Join Date: 2/12/15 Recent PostsI'm afraid only the category id is filtrable: https://help.liferay.com/hc/en-us/articles/360039026232-Filterable-properties
But you can do what you want by filtering by id: taxonomyCategoryIds/any(t:t eq 1)