Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

AEM CLoud GraphQL Filter using string array

Avatar

Level 4

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.

11 Replies

Avatar

Community Advisor

Hi @SDusane 

 

Firstly, the type of param you're trying to filter should be of type string array [String]. Refer to example like below : 

 

PRATHYUSHA_VP_0-1739857527090.png

 

If it's not string array parameter, try something like below : 

 

PRATHYUSHA_VP_1-1739857741198.png

 

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

 

Hope this helps

 

Thanks

 

Avatar

Level 4

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.

Avatar

Community Advisor

@SDusane 

 

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

 

Thanks

Avatar

Level 4

Hi @PRATHYUSHA_VP 

 

It is like 

"deliveryGroup": [
            "group1",
            "group2"
          ]

 

Thanks.

Avatar

Community Advisor

Hi @SDusane 

 

String[] looks for exact same match, so try something like below -

 

PRATHYUSHA_VP_0-1739872513134.png

 

Below is the thread which explains similar query -

 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/graphql-array/td-p/425661

 

Hope this helps 

 

Avatar

Community Advisor

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"]
}

Avatar

Level 4

Thanks @AmitVishwakarma 

I could see this error

 

SDusane_0-1739933760692.png

 

 

IN is not the value we can use.

 

Thanks.

Avatar

Administrator

@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

Avatar

Level 6

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.

Avatar

Level 2

Did you finally figure out filtering string array

Avatar

Level 4

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.