Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Extend GraphQL Content Fragment Model Result

Avatar

Level 1

Hello,

 

In our project we are using the GraphQL solution to obtain information from Content Fragments and render it through React components.
We have created a series of persistedQueries to retrieve the information and everything works as indicated in the documentation, but we have encountered a small problem.

The CFM on which we retrieve the data, has classification information based on Tags, and when retrieving those fields, it only returns the tag path information, but not its title (categoryTag

{
  "data": {
    "articleList": {
      "items": [
        {
          "type": "new",
          "_path": "/content/dam/uoc-common/news/ca/114-ciutat-15-minuts",
          "detailPageUrl": "/content/dam/uoc-common/news/ca/114-ciutat-15-minuts",
          "categoryTag": [
            "/content/cq:tags/news/categories/economy"
          ],
          "title": "La ciutat dels quinze minuts caminant comença per unes voreres que facilitin la mobilitat",
....

 

and of course to be able to present it in the react component we are interested in its localized title. Something like this:

"categoryTag": [{
  "_path": "/content/cq:tags/news/categories/economy",
  "title": "Economy"
}],

 

Is there any way to extend the result of the persisted queries to be able to customize the return of some fields?
Looking in the documentation or debugging the process of creating schemes or executing the queries I have not found the way.

thank you very much,

 

Thanks,

 

Joan Manel

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Level 1

Thanks for the reply @iamnjain and @Saravanan_Dharmaraj 

 

We had already thought about using the Query Builder API solution instead of GraphQL, but since the Adobe AEM roadmap seems focused on enhancing the solution of persistent queries to obtain content fragment data, it seemed better to go in that direction.
As a workaround, we have implemented an api to get the titles of the tags from their paths, and from the frontend we first retrieve the GraphQL data, and then we complete it with a second call, but this is just a patch, since we just have this problem, it is very likely that we have to retrieve other information that right now cannot be returned through the persisted queries (such as, incomprehensibly, the total number of results in the paginated queries...)
We will keep trying to find a solution to extend the query result on the server side without penalizing performance...

View solution in original post

3 Replies

Avatar

Community Advisor

Hello @JoanManelGarcia 

 

I think you can not do this customization in AEM GraphQL as it's scope is limited. For this, you need to use traditional AEM method to fetch this title, you can use Query Builder API and AEM Java code.

 

Hope this helps.

Avatar

Correct answer by
Level 1

Thanks for the reply @iamnjain and @Saravanan_Dharmaraj 

 

We had already thought about using the Query Builder API solution instead of GraphQL, but since the Adobe AEM roadmap seems focused on enhancing the solution of persistent queries to obtain content fragment data, it seemed better to go in that direction.
As a workaround, we have implemented an api to get the titles of the tags from their paths, and from the frontend we first retrieve the GraphQL data, and then we complete it with a second call, but this is just a patch, since we just have this problem, it is very likely that we have to retrieve other information that right now cannot be returned through the persisted queries (such as, incomprehensibly, the total number of results in the paginated queries...)
We will keep trying to find a solution to extend the query result on the server side without penalizing performance...