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.

AEM Headless content Delivery via GraphQL

Avatar

Level 5

Hello All,

I am currently trying to enable AEM headless delivery approach and this would need to be totally decoupled i.e. front-end app resides totally out of AEM (No AEM SPA )

 

Recommendation seems to be to use GraphQL and Content Fragments, however I have a question:

How would page assembly be controlled by Authors in such a case, i,e. the way authors are able to decide which component should go first on page and which after that - meaning maintaining page structure?

 

Thanks in advance.

@

 

 

3 Replies

Avatar

Community Advisor

Hi @asn11 

It Depends on your requirement

a) If you want to expose only a snippet of text then Using Content Fragment you can directly expose as Json.Also you can create a Content Fragment Model if you need additional widgets without layout.Content Fragment need not be part of any page content inorder to expose the json this can be done using asset api.

 

b) Similarly if you want to expose a content with layout then you cant use Content fragment in that case you use Experience Fragment in which you can add multiple components and expose as JSON OOTB.

 

Irrespective of the author placing the page components you can control the exposing of required JSON structure like which components and which data in that component using Graphql itself.

 

Hope this helps.

 

Regards,

Rajashankar.R

 

c) You can also create a page with set of components and control what data you want to expose from  components using JSON exporter at component level. or else you can use ootb json model to expose the page json along with components

 

d) You can also create a custom Servlet which can expose the json structure.

 

Now for all of the above methods you can use Graphql as a middle layer as a wrapper on top of it and expose only required data elements in this json.

 

 

 

 

Avatar

Level 5

thanks for your response ,

a) - Is not requirement because exposing only CF individually will have no info about its placement on resulting page

b) experience fragments are not meant to be exposed via GraphQL api as far as I know.

c) This could have been an option, although graphQL does not work with page/component export as of now , only CFs can be exported with GraphQL.

But this would mean we use components and whenever an additional authoring field is needed to be added, we have to have development associated to add dialog fields as well as exporters