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?
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:
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)
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?
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:
Instead of using the _dynamicUrl field, retrieve the image URL directly from the fileReference field of the ImageRef type.
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.