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:
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.
Solved! Go to Solution.
Views
Replies
Total Likes
+ as a operator cannot be used in a GrapqhQL query, especially for _path, since its data type is not String rather ID data type, hence String operations cannot be performed for _path/
For Requirement 1: You might have to change your solution approach, where in you can add a unique id to each folder, which can then be filtered using String Type.
For Requirement 2: Please find the sample code attached
query {
cityList(filter: {
categories: {
_expressions: [
{
values: [
"city:beach",
"city:na"
]
}
]
}
}) {
items {
name
population
country
categories
}
}
}
+ as a operator cannot be used in a GrapqhQL query, especially for _path, since its data type is not String rather ID data type, hence String operations cannot be performed for _path/
For Requirement 1: You might have to change your solution approach, where in you can add a unique id to each folder, which can then be filtered using String Type.
For Requirement 2: Please find the sample code attached
query {
cityList(filter: {
categories: {
_expressions: [
{
values: [
"city:beach",
"city:na"
]
}
]
}
}) {
items {
name
population
country
categories
}
}
}
@krati_garg Could you please elaborate the solution for Requirement 1? How do I add the unique ID? Do you mean to add it as a field in the model and filter by that?
Views
Replies
Total Likes
Views
Likes
Replies