With Adobe Experience Manager (AEM), you can use Content Fragments, together with the AEM GraphQL API (a customized implementation, based on standard GraphQL), to headlessly deliver structured content for use in your applications. The ability to customize a single API query allows you to retrieve and deliver the specific content that you want/need to render (as the response to the single API query).
GraphQL is currently used in two (separate) scenarios in Adobe Experience Manager (AEM):
A Headless Content Management System (CMS) is:
"A headless content management system, or headless CMS, is a back-end only content management system (CMS) built from the ground up as a content repository that makes content accessible via an API for display on any device.
In terms of authoring Content Fragments in AEM this means that:
You can use Content Fragments to author content that is not primarily intended to be directly published (1:1) on formatted pages.
The content of your Content Fragments will be structured in a predetermined manner - according to the Content Fragment Models. This simplifies access for your applications, which will further process your content.
“…a query language for APIs and a runtime for fulfilling those queries with your existing data.”.
The AEM GraphQL API allows you to perform (complex) queries on your Content Fragments; with each query being according to a specific model type. The content returned can then be used by your applications.
For Adobe Experience, a customized implementation of the standard GraphQL API has been developed. See AEM GraphQL API for use with Content Fragments for details.
The AEM GraphQL API implementation is based on the GraphQL Java libraries.
Content Fragments can be used as a basis for GraphQL for AEM queries as:
Contain structured content.
They are based on a Content Fragment Model, which predefines the structure for the resulting fragment.
These Content Fragment Models:
Are used to generate the Schemas, once Enabled.
Provide the data types and fields required for GraphQL. They ensure that your application only requests what is possible, and receives what is expected.
The data type Fragment References can be used in your model to reference another Content Fragment, and so introduce additional levels of structure.
The Fragment Reference:
Is of particular interest in conjunction with GraphQL.
Is a specific data type that can be used when defining a Content Fragment Model.
References another fragment, dependent on a specific Content Fragment Model.
Allows you to retrieve structured data.
To help with designing and developing your Content Fragment Models, you can preview JSON output.
See Learning to use GraphQL with AEM - Sample Content and Queries for an introduction to using the AEM GraphQL API.
Looking for a hands-on tutorial? Check out Getting Started with AEM Headless and GraphQL end-to-end tutorial illustrating how to build-out and expose content using AEM’s GraphQL APIs and consumed by an external app, in a headless CMS scenario.