AEMaaCS GraphQL Web Optimized Images not working | Community
Skip to main content
Level 3
June 23, 2023

AEMaaCS GraphQL Web Optimized Images not working

  • June 23, 2023
  • 2 replies
  • 1483 views

We are trying to use the _dynamicUrl feature of GraphQL when using an "ImageRef" in our GraphQL query, but we are getting errors when trying to do so.

 

"Validation error of type FieldUndefined: Field '_dynamicUrl' in type 'ImageRef' is undefined @ 'awardList/items/logo/_dynamicUrl'"

 

We have tried this in the local development environment, a hosted environment with the latest version deployed, as well as a Sandbox environment with the latest version deployed.  None of them are able to use this field to return the _dynamicUrl for the image.

 

The documentation we followed is here: https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/content-fragments.html?lang=en#web-optimized-image-delivery-in-graphql-queries

 

There does not seem to be any additional setup steps to enable this functionality.

 

Is anyone able to provide help to get this working?

 

Thank you!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 23, 2023

The error is clear the _dynamicUrl field does not exist in the imageRef object, when I look at the references available, I just see this, is it possible you mistaken the name of what you are looking for? Also you can use the "Documentation Explorer" in the right section of the ghrapql UI(http://localhost:4502/aem/graphiql.html)  to check which objects are available like I show below:

 

Esteban Bustamante
Level 3
June 23, 2023

Hi @estebanbustamante you are correct, it's not there, however, the documentation that I linked to clearly indicates that it should be there on the ImageRef, which is why I've asked this question - why is it not there?

 

See this for reference - https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/content-fragments.html?lang=en#web-optimized-image-delivery-full-parameters (Note the _dynamicUrl on ImageRef)

Level 3
June 28, 2023

I see, sorry about the confusion, it looks like the web optimizer needs to be enabled somehow for that dataType used in the content fragment model in order to enable that property in the ImageRef, but as you pointed out, there seems to be some step missing, I guess you verified your instances can access the Web Optimizer in the regular image core component? Is that piece working? 


Yes sir, Web Optimized Images do work when using the Core Image component.

Tanika02
Level 7
June 23, 2023

Hello @leeasling1 - 

 

Are you working on AEM on prem or AEM as a cloud service?

 

As the documentation link that you have shared (https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/headless/graphql-api/content-fragments.html?lang=en#web-optimized-image-delivery-full-parameters) is that of AEM as a cloud service and the _dynamicUrl field for the ImageRef type is not available in AEM 6.5 on-premise or earlier versions. It was introduced in AEM as a Cloud Service and is not available in on-premise deployments.

 

 

However, to provide the dynamic URL for an image in GraphQL, you can use a different approach.

 

Here's an alternative solution you can try:

 

  1. Instead of using the _dynamicUrl field, retrieve the image URL directly from the fileReference field of the ImageRef type.

  2. Once you have the fileReference value, you can construct the dynamic URL using the hostname and the path to the image file. In AEM, the image URLs can typically be constructed as follows:https://{hostname}/{path_to_image_file}
  3. By constructing the URL manually, you can achieve the same result as the _dynamicUrl field, which is to obtain a dynamic URL for the image.

 

 

 

 

 

 

Level 3
June 28, 2023

Hi @tanika02 - we are using AEMaaCS, as noted in the title.

I appreciate the workaround, however, I shouldn't have to use a workaround for documented functionality.

 

Can anyone at Adobe help with this?