Managing internal and external links in Content Fragments and Graphql
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)?