cc @arunpatidar @giuseppebag @SantoshSai @HrishikeshKagne
Thanks in advance
해결되었습니다! 솔루션으로 이동.
조회 수
답글
좋아요 수
Your Content Fragment Model’s “content reference” field (Logo) is returning a GraphQL type of ImageRef, and in AEM, that type does not include _metadata or metadata fields.
Only Content Fragments have a _metadata property exposed through GraphQL.
Assets (images, PDFs, etc.) referenced via a content-reference or media field in a fragment are not treated as GraphQL nodes, just lightweight objects with:
_path
mimeType
width
height
altText
That’s why your query:
metadata {
stringArrayMetadata {
name
value
}
}
throws a validation error - because metadata isn’t part of ImageRef schema.
If you really want the asset’s cq:tags available through GraphQL:
Create a custom Sling Model that extends your fragment output.
Inject the referenced asset’s Resource (from the content-reference field).
Read cq:tags from /jcr:content/metadata.
Add a new getter, eg getAssetTags().
Annotate with @GraphQLField and register it via the GraphQL extensions bundle.
That will let you query:
Logo {
_path
width
height
assetTags
}
This requires OSGi bundle + code deployment but works cleanly without changing GraphQL schema manually.
조회 수
답글
좋아요 수
hi @Mahesh_Gunaje,
GraphQL API is primarily designed for Content Fragments, not standalone DAM assets. Direct asset metadata (including tags from /jcr:content/metadata/cq:tags) cannot be queried via GraphQL unless the asset is referenced through a Content Fragment.
First, create a Content Fragment model with a "Content Reference" field type that points to assets, i.e. it accepts only images as type. Then, execute a query to retrieve asset metadata from the referenced asset (here CF field name is assetReference):
{
myContentFragmentList {
items {
assetReference {
... on ImageRef {
_path
_authorUrl
_publishUrl
_metadata {
stringArrayMetadata {
name
value
}
}
}
}
}
}
}
조회 수
답글
좋아요 수
Hi @Mahesh_Gunaje,
The GraphQL capabilities are limited to Content Fragments, not Assets.
That’s why you’re able to expose metadata and tags for a Content Fragment but not directly for a DAM asset.
Ideally, when you create a GraphQL endpoint, it only exposes:
Content Fragment fields (and references),
Metadata you’ve modeled in the fragment model, and
Related assets referenced by those fragments (via reference or media type fields).
I would, Expose asset data via Content Fragment reference
Add a field in your fragment model to reference an asset.
Add a custom Sling Model or servlet that reads the asset’s metadata (like cq:tags) and exposes it as a computed field.
Example: Create a custom GraphQL schema extension that adds a tags property by reading asset.getMetadata("cq:tags").
Forgot to give you more contexts. My bad.
Note: My CF model has content reference field, there I have selected a DAM image(which has tags assigned to) path.
Now, when I write below mentioned query, getting error: Field '_metadata' in type 'ImageRef' is undefined",
Thanks
Mahesh
조회 수
답글
좋아요 수
Your Content Fragment Model’s “content reference” field (Logo) is returning a GraphQL type of ImageRef, and in AEM, that type does not include _metadata or metadata fields.
Only Content Fragments have a _metadata property exposed through GraphQL.
Assets (images, PDFs, etc.) referenced via a content-reference or media field in a fragment are not treated as GraphQL nodes, just lightweight objects with:
_path
mimeType
width
height
altText
That’s why your query:
metadata {
stringArrayMetadata {
name
value
}
}
throws a validation error - because metadata isn’t part of ImageRef schema.
If you really want the asset’s cq:tags available through GraphQL:
Create a custom Sling Model that extends your fragment output.
Inject the referenced asset’s Resource (from the content-reference field).
Read cq:tags from /jcr:content/metadata.
Add a new getter, eg getAssetTags().
Annotate with @GraphQLField and register it via the GraphQL extensions bundle.
That will let you query:
Logo {
_path
width
height
assetTags
}
This requires OSGi bundle + code deployment but works cleanly without changing GraphQL schema manually.
조회 수
답글
좋아요 수