Hi @franciscomu1,
Not directly, but GraphQL only supports querying Content Fragments, because:
1. Programmatically Create Content Fragments per Asset (Automated CF generation)
-
If CFs are required, write a one-time job/script that loops through assets in a folder and creates CFs for each.
-
You can even associate the asset via a contentReference field in the CF.
Adobe provides APIs for CF creation:
ContentFragment cf = contentFragmentManager.create("/path/to/model", "cf-name", "/target/path", properties);
This gives you GraphQL capability without manual effort.
2. Use a Shared "Global Asset Index" CF (Your JSON idea)
You can create one large Content Fragment with a model like this:
GlobalAssetIndex CFM:
{
"assets": [
{
"title": "Asset 1",
"path": "/content/dam/assets/asset1.jpg",
"tags": ["product", "promo"]
},
{
"title": "Asset 2",
"path": "/content/dam/assets/asset2.jpg",
"tags": ["banner"]
}
]
}
Then expose this single CF via GraphQL and query it like:
{
globalAssetIndexByPath(_path: "/content/dam/global-index") {
item {
assets {
title
path
tags
}
}
}
}
3. Create a Custom Servlet for JSON Access (outside GraphQL)
If GraphQL is not mandatory, you can:
But this won’t be usable via GraphQL APIs - it’s a REST endpoint, not GraphQL.
Best Approach Recommendation
If GraphQL access is mandatory, then:
-
Create a global “index” CF (option 2 above)
-
Auto-generate its JSON using a scheduled job or manual script
-
Or - if you need fine granularity, auto-create CFs for each asset and link them
Hope that helps!