If you’re working on an XM Cloud or XMPaaS project (with Edge), you’re going to have to get very comfortable with Graph. Why? Literally everything uses it. In order to get content out of Edge, or even your preview Edge endpoint, Graph is your language. It’s ok though, because it’s not stupid and it actually makes sense. (We may take that for granted, but we all remember SIF…)
Anyway, there’s some good documentation about some useful queries. Here’s a few others though that you may run into a need for:
Fetch the link to your current Sitemap.xml file:
query SitemapQuery($siteName: String!) {
site {
siteInfo(site: $siteName) {
sitemap
}
}
}
Fetch the contents of your robots.txt file:
query RobotsQuery($siteName: String!) {
site {
siteInfo(site: $siteName) {
robots
}
}
}
Fetch all the redirects in your system (the ones that aren’t in your next.config.js, anyway):
query RedirectsQuery($siteName: String!) {
site {
siteInfo(site: $siteName) {
redirects {
pattern
target
redirectType
isQueryStringPreserved
locale
}
}
}
}
Fetch the current contents of your 404/500 page (this one is language-specific, so be aware of the extra parameter!)
query ErrorPagesQuery($siteName: String!, $language: String!) {
site {
siteInfo(site: $siteName) {
errorHandling(language: $language) {
notFoundPage {
rendered
}
notFoundPagePath
serverErrorPage {
rendered
}
serverErrorPagePath
}
}
}
}
Fetch all the values currently stored in your dictionary.
- The rootItemID is item which lies at /sitecore/content/<TENANT>/<SITE>/Dictionary
- Templates ID is the template ID of the dictionary entries themselves (most likely {6D1CD897-1936-4A3A-A511-289A94C2A7B1})
query DictionarySearch(
$rootItemId: String!
$language: String!
$templates: String!
$pageSize: Int = 10
$after: String
) {
search(
where: {
AND: [
{ name: "_path", value: $rootItemId, operator: CONTAINS }
{ name: "_language", value: $language }
{ name: "_templates", value: $templates, operator: CONTAINS }
]
}
first: $pageSize
after: $after
) {
total
pageInfo {
endCursor
hasNext
}
results {
key: field(name: "Key") {
value
}
phrase: field(name: "Phrase") {
value
}
}
}
}
Bonus Note: One of the unsung heroes of your build, at least in the first parts, is going to be the “PURGE OF DOOM” as I call it. This request allows you to wipe your Edge instance completely clean, in case you jack something up along the ways. Here’s the official docs to it: https://doc.sitecore.com/xp/en/developers/101/developer-tools/admin-api.html#UUID-d14f0bed-6692-4865-4e3f-589f23967400_N1631784656638
This one is a “You probably don’t want to run this in production, so be extra sure that your JWT points to the right environment and I’ve never accidentally purged the wrong instance myself, so be better….” kinda thing. So use at your own risk!