cmsPage and cmsBlocks GraphQL Query Magento used to display CMS related information.
You can use cmsPage for the CMS Page related data whereas cmsBlock used to display CMS Static Block related information.
schema.graphql file for the CMS module will be available on file, vendor/magento/module-cms-graph-ql/etc/schema.graphqls
Example with a query,
1) CMS Page Query,
{
cmsPage(
identifier: "home"
) {
identifier
meta_keywords
meta_title
meta_description
page_layout
content
content_heading
title
url_key
}
}
You need to pass the identifier value of the cms page to retrieve information on the specific Page. I have used the home as an identifier to fetch data of HomePage.
The Output will be Page related Data.
2) CMS Static Block Query,
{
cmsBlocks(
identifiers: ["1","2","3"]
) {
items {
title
content
identifier
__typename
}
}
}
You have to pass a string of arrays as the identifier value of the static block.
Correct Value:
identifiers: ["1","2","3"]
Incorrect Value:
identifiers: [1,2,3] // Must have string identifier
identifiers: [String] @doc(description: "Identifiers of the CMS blocks")
You can add one or more of the static block ids as a string in identifiers.
The output will be the identifier, title, and content of the static block.
You can be also interested to check, How to Use Product Query GraphQl Magento 2?
