GraphQL request for a page, resolving links on the fly
You can resolve Component links within a page call using the resolvedLink property, which allows you to drill down into the linked page without having to execute a new GraphQL call.
The example below assumes the following setup:
- A page can contain Components based on a Component Schema called
Article. ArticleComponents have:- a
textFieldfield of type text, containing some text - a
deepDiveLinkfield of type Component link, containing a link to another Component with more background information
- a
- In this example, the Component link references a Component based on a Component Schema called
Whitepaper.
In the page API call, resolvedLink is used within the call to drill down to the page being referenced by the resolved link, and to explore and display its regions, subregions and Components.
p1: page(namespaceId: 1,publicationId:5, pageId:393) {
title
regions {
components {
title
...on Article {
textField
deepDiveLink {
title
...on Whitepaper {
resolvedLink {
url
page {
__typename
title
itemId
regions {
name
components {
title
}
regions {
name
components {
title
}
}
}
}
}
}
}
}
}
}
}