AEM CLoud GraphQL Filter using string array | Community
Skip to main content
New Participant
February 18, 2025

AEM CLoud GraphQL Filter using string array

  • February 18, 2025
  • 4 replies
  • 1816 views

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.

4 replies

New Participant
July 10, 2025

Did you finally figure out filtering string array

SDusaneAuthor
New Participant
July 11, 2025

No all the solutions given above didn't work for string array so I read all the data from graphQL and filter the results on frontend.

Uppari_Ramesh
New Participant
February 20, 2025

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.

AmitVishwakarma
New Participant
February 18, 2025

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"] }
SDusaneAuthor
New Participant
February 19, 2025

Thanks @amitvishwakarma 

I could see this error

 

 

 

IN is not the value we can use.

 

Thanks.

kautuk_sahni
Employee
March 4, 2025

@sdusane Did you find the suggestions helpful? Please let us know if you need more information. If a response worked, kindly mark it as correct for posterity; alternatively, if you found a solution yourself, we’d appreciate it if you could share it with the community. Thank you!

Kautuk Sahni
PRATHYUSHA_VP
New Participant
February 18, 2025

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 --

 

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql-api/sample-queries#sample-all-persons-jobs-smith

 

Hope this helps

 

Thanks

 

SDusaneAuthor
New Participant
February 18, 2025

Hi @prathyusha_vp 

 

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.

PRATHYUSHA_VP
New Participant
February 18, 2025

@sdusane 

 

Can you send the type of parameter for deliveryGroup in CF field ?

 

Thanks