AEM 6.5 | Graphql query to fetch Tags | Community
Skip to main content
Mukesh_Kumar_Co
Level 3
December 9, 2022
Solved

AEM 6.5 | Graphql query to fetch Tags

  • December 9, 2022
  • 1 reply
  • 2802 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by krati_garg

@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

1 reply

krati_garg
Adobe Employee
krati_gargAdobe EmployeeAccepted solution
Adobe Employee
December 9, 2022

@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
December 9, 2022

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
December 9, 2022

can you give an example of the expected response @mukesh_kumar_co