Expand my Community achievements bar.

AEM 6.5 Graphql Query for UUID

Avatar

Level 3

Is there any unique identifier available which we can use while fetching Content Fragments content? I know AEM has jcr:UUID as a unique identifier for all content but I can't access it in the Graphql query.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

8 Replies

Avatar

Level 8

Hi @Mukesh_Kumar_Co 

 

Have you tried using path as an unique identifier. You can refer the documentation for further details and an example query for the same - https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/graphql...

 

Hope this helps!

 

Thanks

Narendra

_path returns a relative path which change after author move the content to another folder. I'm looking for some ID which should be unique and not change for a content.

Avatar

Community Advisor

Hi @Mukesh_Kumar_Co 

In AEM, Content Fragments have a unique identifier called `cq:contentFragment`, which can be used to fetch the content fragment's content. This identifier remains constant even if the content fragment is moved to another folder.

To fetch the content of a specific Content Fragment using its unique identifier, you can use the `cq:contentFragment` property in your GraphQL query. 

{
  contentFragmentByPath(path: "/content/dam/my-site/my-fragment") {
    cq:contentFragment {
      elements {
        title
        description
        // other fields
      }
    }
  }
}



In the above example, `cq:contentFragment` is used to fetch the content of the Content Fragment located at `/content/dam/my-site/my-fragment`. You can replace this path with the actual path of your Content Fragment.



Avatar

Level 3

@Raja_Reddy I tried to execute the above query in my AEM instance but it shows the error attached in the screenshot. Wondering if I'm missing something.
I wanted to query all the content fragments available at a path along with a unique ID. Can you share the query please?

Mukesh_Kumar_Co_0-1712599514779.png

 

Avatar

Level 3

Thanks @Raja_Reddy for your quick response. I'm using the on-premise version of AEM 6.5.12 and can't see method contentFragmentByPath in the documentation https://experienceleague.adobe.com/en/docs/experience-manager-65/content/assets/extending/graphql-ap.... Wondering if I'm missing something?

Avatar

Community Advisor

@Mukesh_Kumar_Co Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community



Esteban Bustamante

It seems interesting but somehow I was unable to use the suggested solution in my instance. I have responded with follow-up question.