Pass asset metadata from GraphQL Query
cc @arunpatidar @giuseppebaglio @santoshsai @hrishikeshkagne
Thanks in advance
cc @arunpatidar @giuseppebaglio @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.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.