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.
Simply put, supply chains are the cornerstone of modern businesses. They effectively connect organizations not… Read More
AI is transforming customer service by making it quicker and more intelligent. Chatbots and AI… Read More
In today’s fast-paced, interconnected world, supply chain management is more critical—and more complex—than ever before.… Read More
We are now approaching the year 2025. It is anticipated that video production will continue… Read More
In the digital age, online trading has revolutionised the financial markets. Today, anyone can trade… Read More
When it comes to footwear, some styles never lose their appeal. From classic loafers to… Read More