The regions subquery for a page or typedPage root query
Within a page or typedPage root query, insert a regions subquery to explore the Regions of the Page.
The following query is an example of delving into the Regions of a Page fetched with a
page root query:
page(namespaceId: 1, publicationId: 5, pageId: 371) {
title
regions(filter: "Main, Header, Footer") {
name
components {
title
...on Article {
headline
}
}
# Show child Regions
regions {
name
regions {
name
}
}
...on MainRegion {
metadata {
mainRegionSchemaMetadataField
}
}
}
}
The query fetches various pieces of data at various levels:
- The title of the Page
- The names of the Regions called Main, Header and Footer. The
filterparameter, set to a comma-separated list of Region names, is optional; if not specified, theregionscall returns all Regions. - The titles of any Components in those Regions
- The values of the "headline" fields of any Components in those Regions based on the "Article" Schema
- The names of any Regions within the Main, Header and Footer Regions
- The names of any Regions within those Regions
- The value of the metadata field called
mainRegionsSchemaMetadataFieldwithin the Region calledMainRegion. The metadata is defined by a Metadata Schema for this Region as defined in Content Manager.
Note that constructing a query such as this one requires you to be intimately familiar with the Page you are fetching, its Page Schema, its Regions, and so on.
Based on information you know about the Schemas of the Components in the Regions, you could go further and drill down into the type of Component and fetch individual fields for that type.