Expand my Community achievements bar.

SOLVED

Content Fragment + GraphQL - Expose combined content fragments via single model/graphql api

Avatar

Level 4

Hello Team,

We want to use content fragment + graphql feature to expose headless content. We could achieve individual components model and graphql endpoint to specific content fragment via persisted/http post api.

 

from FE, this could be a problem making a API call for each component from performance point of view. So we want to combine the different content fragment and expose via single api.

Please let us know how we can do this ?

 

Hero Card -> we have individua endpoint for this component

Teaser -> we have individua endpoint for this component

 

But we want to expose for page data combined json data of Hero card and teaser in single endpoint.

Topics

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

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi, 

 

If you are using the page component that inherits from the core components, you can simply take advantage of the Sling model exporter, which comes out of the box, to export all the data from a page[1]. If this is too much or you need to customize, you can simply extend and use the delegation pattern to simplify or modify the information you need to expose.


[1]. For example: http://localhost:4502/content/wknd/us/en.model.json the "model" selector is reserved to expose ootb the data from a page (if the page component inherits from the core component)

EstebanBustamante_0-1707241451743.png

[2]. Delegation pattern: https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models 

 

 

Hope this helps.



Esteban Bustamante

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi, 

 

If you are using the page component that inherits from the core components, you can simply take advantage of the Sling model exporter, which comes out of the box, to export all the data from a page[1]. If this is too much or you need to customize, you can simply extend and use the delegation pattern to simplify or modify the information you need to expose.


[1]. For example: http://localhost:4502/content/wknd/us/en.model.json the "model" selector is reserved to expose ootb the data from a page (if the page component inherits from the core component)

EstebanBustamante_0-1707241451743.png

[2]. Delegation pattern: https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models 

 

 

Hope this helps.



Esteban Bustamante

Avatar

Administrator

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



Kautuk Sahni