GraphQL in Adobe Experience Manager (AEM) is a query language and runtime APIs that allows to request exactly the data which we need. It provides a more flexible and efficient way to access content and interact with AEM than traditional REST APIs.
GraphQL plays important role in supporting a headless architecture in AEM. Headless architecture is an approach in which AEM is decoupled from the presentation layer, allowing content to be delivered to various channels and devices, such as websites, mobile apps, and IoT devices.
Prerequisites: This blog requires knowledge of content fragments models and it is assumed that you have gone through adobe documentation to learn about content fragment models.
For this blog purpose showing steps to create and enable content fragment models which can be used in GraphQL to create endpoint and expose content fragment data in json format.
Title *: GraphQL CF Models
Name *: graphql-cf-models
Content Fragment Models: Selecting content fragment models enable you to define the structure of your content fragments within Assets, which can represent small, reusable pieces of content, such as product descriptions, news articles, bio etc. Content Fragments will be used by GraphQL queries to expose content using GraphQL endpoints.
GraphQL Persistent Queries: Selecting GraphQL Persistent Queries will allow developers to save queries that are stored on the AEM server. Clients can send an HTTP GET request using endpoint with the query name to execute it.
Tap create to save the configuration.
Tap create to save the content fragment model.
Tap Save & Close to save the configuration. This will allow to create bio content fragments inside created folder (GraphQL CF).
Name* : Bio Endpoint
User GraphQL Schema provided by*: GraphQL CF Models
Tap Create to save the endpoint.
The GraphQL endpoints created based on a project configuration only enable queries against models belonging to that project. In this case, the only queries against the Bio models can be used.
GraphQL Integrated Development Environment (GraphiQL) is an interactive web-based tool that allows developers to create, test, and interact with GraphQL APIs. It provides a user-friendly interface for creating, executing, and debugging GraphQL queries. If GraphiQL IDE is not available built-in then please download package from Adobe Software Distribution to install it in AEM.
query allBios{ bioList{ items{ _path name companyName homeTown hobbies skills } }}
Following this blog developers can start using GraphQL to expose content to use outside AEM.
When integrated effectively with AEM, GraphQL can enhance content delivery and management by providing a powerful and flexible way to interact with AEM’s content and data. However, implementing GraphQL in AEM may require custom development and careful consideration of schema design, security, and caching strategies to ensure optimal performance and security.
Written and curated by: Digvijay Singh Tomar, Lead Digital Architect – AEM. You can follow him on Linkedin.
A logo is not just an object, picture, or image. It’s the keystone of your… Read More
Good communication is very important for managing people who have an interest in a project… Read More
You have heard this far too much, and for good reason. Web design is a… Read More
Florida has a large number of individuals that have an interest in real estate and… Read More
Today, no business is an exception in terms of employing Artificial Intelligence. While healthcare facilities… Read More
Choosing an engagement ring is an amazing event that marks the start of a lifelong… Read More