GraphQL request to render the links in a returned Page or Component Presentation
When requesting Pages or Components with GraphQL requests, use the rawContent field to resolve links. In addition, you can pass a contextData argument to return fully qualified domain name (FQDN) links and to specify URL prefixes for links.
General request for a Page or Component Presentation
The query's rawContent() field has a renderContent Boolean argument that lets you control whether or not to render TCDL elements. If set to true, the query also resolves TCDL link tags in your Page or Component.
The following example requests a Page and a Component Presentation:
{
page (pageId: 275292, publicationId: 2287238, namespaceId: 1) {
fileName
rawContent(renderContent: true) {
content
}
}
componentPresentation (namespaceId: 1, publicationId: 19, componentId: 32, templateId: 17) {
title
rawContent(renderContent: true) {
content
}
}
}
In this sample query, you identify the Page for which to resolve links using its own ID (the pageId parameter) and the ID of its Publication (publicationId). Similarly, you identify a Component Presentation using the ID of its Component (componentId), and the Component Template used to render that Component (templateId).
namespaceId identifies the type of content being processed as one of the following:
- Tridion Sites = 1
- Tridion Docs = 2
Configuring fully qualified domain name (FQDN) links
- Your Dynamic Linking configuration and Linking API must be configured properly
- You must include a claim in the
contextDataargument to set the value to"false"for the URI nametaf:tcdl:render:link:relative.
{
page (pageId: 275292, publicationId: 2287238, namespaceId: 1,
contextData: [
{uri:"taf:tcdl:render:link:relative", value:"false", type:BOOLEAN}]) {
rawContent(renderContent: true) {
content
}
}
}
Configuring links to Tridion Docs topics
To resolve FQDN links to Tridion Docs topics , such as when implementing a content mashup, you can override the prefixes configured in the Dynamic Linking configuration for topics or for binaries by specifying your own prefixes.
In the contextData argument, configure claims for the following URI names:
taf:tcdl:render:link:urlprefix— prefix to use for topicstaf:tcdl:render:link:binaryUrlPrefix— prefix to use for binaries
The following example shows a complete GraphQL query for a Page with these claims included (in addition to the claim for return FQDN links):
{
page (pageId: 6437, namespaceId: 1, publicationId: 178,
contextData: [
{uri:"taf:tcdl:render:link:relative", value:"false", type:BOOLEAN},
{uri:"taf:tcdl:render:link:urlprefix", value:"http://topicexample.com", type:STRING},
{uri:"taf:tcdl:render:link:binaryurlprefix", value:"http://binexample.com", type:STRING}]) {
rawContent(renderContent: true) {
data
}
}
}