How to use GraphQL query filter with path and array variable for content fragments?
I'm currently using AEM 6.5 and trying to implement GraphQL and Persisted Query API to retrieve content fragment data. Say my content fragment model's schema type looks like this:
type Message {
_path: ID,
id: String,
body: MultiFormatString
}
Each content fragment has a unique id that is required.
The content fragments are stored under /content/dam/mysite/messages/{pageid}/ folder.
I want to create persisted queries that allow me to retrieve content fragments based on the page id and a list of ids. Specifically, I want to achieve the following:
- Send a pageid as a parameter to retrieve all message content fragments under the specified page folder.
- Send a list containing multiple ids to retrieve a list of message content fragments (like using a WHERE id in $ids condition in SQL).
I'm wondering if it's possible to achieve my goals using only GraphQL and Persisted Query API, or if I need to develop a custom servlet to implement more complicated search logic.
--------------------------
Additionally:
For the 1st requirement, I want to use a filter like this, but AEM does not recognize the + sign in the filter, and the _path's filter does not support regex (Operators).
{
_path: {
_expression: {
value: "/content/dam/mysite/messages/" + $pageid,
_operator: STARTS_WITH
}
}
}
For the 2nd requirement, I have also checked the AEM documentation, but it doesn't mention anything about accepting an array as a parameter or using an array to filter string data.