How to Fetch CMP DAM Listing Cards in Optimizely CMS 12 Using GraphQL
Introduction
In an existing Optimizely CMS 12 application, listing cards are typically populated using CMS content retrieved through the existing EPiServer Search implementation.
As part of an enhancement, we needed to extend this functionality to display approved digital assets from Optimizely Content Marketing Platform (CMP) Digital Asset Management (DAM) alongside the existing CMS content.
Rather than modifying or replacing the existing CMS search implementation, we introduced Optimizely Graph with GraphQL as an additional content retrieval layer for CMP DAM assets.
This approach allows the application to retrieve CMS content and DAM assets independently, process the results, and combine them into a unified listing experience.
In this article, we will walk through the architecture, configuration, and implementation steps required to retrieve CMP DAM assets using Optimizely Graph and display them alongside existing CMS listing cards.
1. Solution Overview
The solution uses two independent content sources:
- CMS Content: Retrieved through the existing EPiServer Search implementation.
- CMP DAM Assets: Retrieved through Optimizely Graph using GraphQL.
Both result sets are processed independently and combined at the application level before being displayed as listing cards.
Architecture Overview
CMS Content CMP DAM
| |
v v
Existing CMS Search Optimizely Graph
| |
v v
CMS Results GraphQL
| |
| v
| DAM Index
| |
| v
| DAM Results
| |
+------------+-------------+
|
v
Data Mapping
|
v
Unified Listing Model
|
v
Listing Cards
The key advantage of this architecture is that the existing CMS search functionality remains unchanged. CMP DAM assets are retrieved separately and merged with CMS results.
This makes the integration easier to maintain and reduces the impact on existing application functionality.
2. Why Use Optimizely Graph?
There are different approaches to retrieving CMP DAM metadata. Two possible options are the CMP REST API and Optimizely Graph.
Option 1: CMP REST API
The CMP REST API can be used to retrieve DAM metadata and asset information.
However, depending on the API usage limits and request volume, applications may encounter rate-limiting responses such as:
HTTP 429 – Too Many Requests
For high-traffic applications, frequent API requests may introduce additional considerations around rate limits, retry handling, and request management.
Option 2: Optimizely Graph
Optimizely Graph provides a GraphQL-based approach to querying indexed content.
For this integration, we use Optimizely Graph as the primary access layer for retrieving CMP DAM metadata.
Some of its advantages include:
- GraphQL-based retrieval: Request only the fields required by the application.
- Flexible queries: Build queries based on listing requirements and search criteria.
- Efficient metadata retrieval: Retrieve relevant asset metadata through GraphQL.
- Scalability: Use an indexed content retrieval layer rather than relying on repeated CMP REST API calls.
- Separation of concerns: Keep DAM retrieval independent of the existing CMS search implementation.
It is important to note that Optimizely Graph does not automatically eliminate all API rate limits. Its actual performance and request limits depend on the configured service and subscription.
For our implementation, Optimizely Graph provides a suitable approach for retrieving DAM assets independently of the existing CMS search.
3. Implementation Steps
Step 1: Request CMP DAM Access
The first step is to request access to Optimizely CMP DAM through Optimizely.
Once access is provisioned and the Graph integration is configured, the required GraphQL endpoint and authentication credentials become available.
For example, the GraphiQL interface may look like:
https://cg.optimizely.com/app/graphiql?auth=SINGLE_KEY
The GraphiQL interface is useful during development because it allows developers to:
- Explore the available GraphQL schema.
- Identify the DAM fields available for querying.
- Build and test GraphQL queries.
- Validate filters and response structures.
Before implementing the GraphQL service, it is recommended to explore the DAM schema and understand how asset metadata is exposed.
Step 2: Store the Graph Single Key Securely
A Graph Single Key is required to authenticate requests to Optimizely Graph.
For security reasons, the key should never be hardcoded into the application or committed to source control.
In an Optimizely DXP environment, the key can be stored securely in the Optimizely PaaS Portal Key Vault.
The application can then retrieve the key server-side when making GraphQL requests.
Authentication flow:
Optimizely PaaS Key Vault
|
v
Graph Single Key
|
v
CMS Application
|
v
Optimizely Graph
This approach keeps sensitive credentials outside the application source code and makes environment-specific configuration easier to manage.
Step 3: Enable and Synchronize DAM Indexing
Before DAM assets can be queried through Optimizely Graph, they must be indexed.
In CMP, navigate to the following location:
Settings
|
v
Organization
|
v
Misc
|
v
Enable & Sync DAM
Enable and synchronize DAM to make the assets available through the Graph integration.
Once synchronization is completed, the indexed DAM assets can be queried using GraphQL.
Important: CMS content and CMP DAM content have separate indexes and authentication keys in this implementation. They must therefore be queried independently.
The application is responsible for combining the results from both sources.
Step 4: Create an OptiDamGraphService
To keep the implementation clean and maintainable, create a dedicated service such as OptiDamGraphService to handle all communication with Optimizely Graph.
The service is responsible for:
- Receiving search criteria and filter information.
- Building the required GraphQL query.
- Adding the authentication key to the request.
- Sending the request to Optimizely Graph.
- Processing the GraphQL response.
- Mapping the returned DAM metadata into application models.
- Returning the DAM documents to the calling controller or application service.
A simplified service invocation could look like this:
var graphResponse =
await _evaluateCMPGraphService.Service
.GetDocuments(apiRequestDto);
Here, the service receives the request DTO containing the required search criteria and returns the matching DAM documents.
Step 5: Map CMS Filters to DAM Filters
One of the important parts of this integration is handling filters consistently across CMS and DAM content.
The listing page uses common filters such as Region or Geography. However, CMS and DAM may store these values differently.
For example, a Geography filter selected by the user may have a corresponding choice value or identifier in the DAM metadata schema.
Therefore, before executing the GraphQL query, the application needs to map the CMS filter values to their corresponding DAM values.
The following code demonstrates this mapping approach:
foreach (var item in cmsData.Filters)
{
if (item.Label.ToLower() == "region" ||
item.Label.ToLower() == "geography")
{
var field = fields
.FirstOrDefault(x => x.Name == "Geography");
if (field != null)
{
foreach (var filter in item.Values)
{
var resolver =
new LookupResolver.LookupResolver();
var englishValue =
resolver.ResolveGeography(filter.Label);
var choice = field.Choices
.FirstOrDefault(
x => x.Name == englishValue
);
if (choice != null &&
!filter.Key.Contains("_"))
{
filter.Key += "_" + choice.Id;
}
}
}
}
}
How does this work?
- Iterate through the filters received from the existing CMS search.
- Identify filters with the label Region or Geography.
- Find the corresponding Geography field in the DAM metadata fields.
- Resolve the selected filter label into its English equivalent using LookupResolver.
- Find the matching choice in the DAM field choices.
- Append the corresponding choice ID to the filter key when a match is found.
For example, a filter selected in the CMS listing may need to be translated into a DAM-specific value before it can be used in the GraphQL query.
This mapping ensures that the same user-selected filter can be applied consistently to both CMS and DAM content.
It also avoids maintaining completely separate filter-selection experiences for the two content sources.
Step 6: Fetch and Combine CMS and DAM Listing Cards
Once the filter mapping is completed, the application can retrieve DAM assets through OptiDamGraphService.
At this stage, we have two independent result sets:
CMS Search Results
Retrieved using the existing EPiServer Search implementation.
CMP DAM Graph Results
Retrieved using Optimizely Graph through the dedicated Graph service.
Both result sets are then mapped into the application's unified listing model.
The final model can be used by the existing listing component to display CMS content and DAM assets together.
End-to-End Implementation Flow
The complete request flow looks like this:
User Request
|
v
Listing Controller
|
+-----------+-----------+
| |
v v
Existing CMS Search OptiDamGraphService
| |
v v
CMS Index Optimizely Graph
|
v
DAM Index
|
v
DAM Assets
| |
+-----------+-----------+
|
v
Filter / Data Mapping
|
v
Unified Listing Model
|
v
Listing Cards
This approach allows both content sources to operate independently while providing a single listing experience to the end user.
4. Key Benefits of This Approach
Integrating CMP DAM through Optimizely Graph provides several architectural and implementation benefits.
1. Existing CMS functionality remains unchanged
The existing EPiServer Search implementation continues to retrieve CMS content without requiring major changes.
2. Independent content retrieval
CMS and DAM assets are retrieved separately, making the integration easier to maintain and troubleshoot.
3. Centralized GraphQL integration
All GraphQL communication is handled through a dedicated service rather than being implemented directly inside controllers.
4. Consistent filtering experience
CMS filter values are mapped to their corresponding DAM metadata values, allowing the same filters to be applied across both content sources.
5. Secure credential management
The Graph Single Key is stored in the DXP Key Vault rather than being hardcoded in the application.
6. Flexible architecture
Additional DAM fields, filters, or metadata can be incorporated without replacing the existing CMS search functionality.
5. Conclusion
Integrating CMP DAM with Optimizely CMS 12 using Optimizely Graph and GraphQL provides an effective way to extend an existing CMS search experience.
Instead of replacing the existing search implementation, this approach introduces CMP DAM as a second content source.
DAM assets are enabled and indexed in Optimizely Graph, retrieved through a dedicated Graph service, mapped to the existing CMS filters, and combined with CMS search results at the application level.
The result is a unified listing experience where both CMS content and approved CMP DAM assets can be displayed together as listing cards.
Most importantly, this architecture preserves the existing CMS functionality while introducing a separate and maintainable integration layer for DAM content.
Comments