Content Fragment + GraphQL - Expose combined content fragments via single model/graphql api | Community
Skip to main content
Level 3
February 5, 2024
Solved

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

  • February 5, 2024
  • 2 replies
  • 663 views

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.

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 EstebanBustamante

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)

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

 

 

Hope this helps.

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
February 6, 2024

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)

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

 

 

Hope this helps.

Esteban Bustamante
kautuk_sahni
Community Manager
Community Manager
February 8, 2024

@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