We are starting to use Content Fragments with GraphQL in AEM but found ourselves with a problem regarding links in CFs.
We have some Content Fragment models which have a Reference to pages, the client use this as a link or related content (using the PageRef's helper field _publishUrl).
The problem is that now we have some cases in which we need to point to a link that is not within AEM (external sites & deep links to mobile apps). These external links will return null if used in a Content Reference field in the CF.
Example using this in a query:
link {
... on PageRef{
_publishUrl
}
}
Will work fine if the field link points to an AEM page (which is to expect) but will return null if the author wrote https://example.com. One workaround would be to have 2 fields, but that seems cumbersome and a burden to the client.
What is the correct way to be able to manage links that could be either internal (pointing to pages within that AEM instance) or external (third party URLS)?
Just out of curiosity was a solution ever provided or discovered?
Views
Replies
Total Likes
Hello @santiagozky , @ClintLundmark : Have you guys found any solution to this?
Views
Replies
Total Likes
This is not a particularly good solution, but we had to move on, so it is what we did. It's more of a workaround or compromise.
In the Content Fragment Model, we have two properties that can be used for the link.
In the GraphQL query we display PageRef and DocumentRef for the actionLinkInternal property and also output the actionLinkExternal property.
actionLinkInternal {
... on PageRef {
_path
_publishUrl
}
... on DocumentRef {
_path
_publishUrl
}
}
actionLinkExternal
The consuming application will have logic something like if there is a value in actionLinkExternal use that, otherwise use actionLinkInternal.
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies