Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

AEMaaCS GraphQL Web Optimized Images not working

Avatar

Level 2

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-ap...

 

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!

6 Replies

Avatar

Community Advisor

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:

Esteban666_0-1687531751143.png

 



Esteban Bustamante

Avatar

Level 2

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-ap... (Note the _dynamicUrl on ImageRef)

Avatar

Community Advisor

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? 



Esteban Bustamante

Avatar

Level 2

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

Avatar

Community Advisor

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-ap...) 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.

 

 

 

 

 

 

Avatar

Level 2

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?