Hi Team,
Could you please help me on GraphQL persistent queries.
The use case is I want to pass some group names in query paramaters and I want to filter the CF's matching with any group name.
I am using query like this
query ($userGroups: [String]!) {
sNewFragmentList(filter: {
deliveryGroup: {
_expressions: [
{
values: $userGroups
_operator: CONTAINS
}
]
}
}) {
items {
_path
title
description
deliveryGroup
}
}
}
And I am passing parameters as
{
"userGroups": "group1,group2,group3"
}
This query is not working at all, could anyone pls help me to check every group from the parameters list and filter only those fragments.
Thanks.
Views
Replies
Total Likes
Hi @SDusane
Firstly, the type of param you're trying to filter should be of type string array [String]. Refer to example like below :
If it's not string array parameter, try something like below :
You can update, operator parameter (_operator) as per your requirement
Here's the similar example in experience league docs --
Hope this helps
Thanks
Thanks for the help!
I am trying below query
query ($userGroups: [String]) {
sNewFragmentList(
filter: {
deliveryGroup: {
_logOp: OR,
_expressions: [{
values: $userGroups,
_operator: CONTAINS
}]
}
}
) {
items {
title
description
deliveryGroup
}
}
}
With the query parameter
{
"userGroups": ["group1","group2"]
}
It is still not working. If I give only 1 parameter the query is working but not with array values.
Can you pls suggest me some fix.
Thanks.
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi @SDusane
String[] looks for exact same match, so try something like below -
Below is the thread which explains similar query -
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/graphql-array/td-p/425661
Hope this helps
Views
Replies
Total Likes
Hi @SDusane ,
Change _operator: CONTAINS to _operator: IN for matching arrays.
Query: Checks if any value in the userGroups array matches values in the deliveryGroup array.
query ($userGroups: [String]) {
sNewFragmentList(
filter: {
deliveryGroup: {
_logOp: OR,
_expressions: [{
values: $userGroups,
_operator: IN
}]
}
}
) {
items {
title
description
deliveryGroup
}
}
}
{
"userGroups": ["group1", "group2"]
}
Views
Replies
Total Likes
Hi @SDusane , could you please try below filter? Ensure you have name as VALUE instead of VALUEs
filter: {deliveryGroup: {_expressions: [{value: $userGroups, _operator: CONTAINS}]}}
Thanks,
Ramesh.
Views
Replies
Total Likes
Views
Likes
Replies