Skip to main content
Mukesh_Kumar_Co
Level 3
12月 9, 2022 11:19 午前 UTC
解決済み

AEM 6.5 | Graphql query to fetch Tags

In my custom react application, I wanted to fetch and show one of the Tag values. Wondering if I can do it using Graphql query.

このトピックへの返信は締め切られました。
krati_garg
Adobe Employee
12月 9, 2022 1:41 午後 UTC

@mukesh_kumar_co 
If tags are stored on Content Fragment itself, then it can be achieved via following: 
query {
cityList(
filter: {_tags: {_expressions: [{value: "tourism:city-break", _operator: CONTAINS}]}}
){
items {
name,
_tags
}
}
}

Or

 

If these tages are on Content Fragment Metadata, then it can be achieved, via:

{
adventureList {
items {
          _path,
          _metadata {

                stringArrayMetadata {
                               name,
                               value
                }
         }
   }
}
}

You will get all the metadata properties with String Array as Data Type, including cq:tags

5 の返信

krati_garg
Adobe Employee
Adobe Employee
12月 9, 2022 1:41 午後 UTC

@mukesh_kumar_co 
If tags are stored on Content Fragment itself, then it can be achieved via following: 
query {
cityList(
filter: {_tags: {_expressions: [{value: "tourism:city-break", _operator: CONTAINS}]}}
){
items {
name,
_tags
}
}
}

Or

 

If these tages are on Content Fragment Metadata, then it can be achieved, via:

{
adventureList {
items {
          _path,
          _metadata {

                stringArrayMetadata {
                               name,
                               value
                }
         }
   }
}
}

You will get all the metadata properties with String Array as Data Type, including cq:tags

翻訳
Mukesh_Kumar_Co
Level 3
12月 9, 2022 1:54 午後 UTC

Thanks for your prompt response @krati_garg. Actually, I wanted to fetch the Tag based on the path and their child element only. Wondering if Graphql supports that.

翻訳
krati_garg
Adobe Employee
Adobe Employee
12月 9, 2022 2:13 午後 UTC

can you give an example of the expected response @mukesh_kumar_co 

翻訳