How to Get CMS Page Information Using GraphQL in Magento 2

Do you want to know how to get cms page information using GraphQL Query in Magento 2?

In this Magento 2 GraphQL Tutorial, We will show how to get cms page information using GraphQL Query in Magento 2. We will use the {cmsPage} query to get information about a CMS page information of your store.

Let’s start!

Get CMS Page Query:

The {cmsPage} query can returns CMS page information. Here you must include the CMS page identifier value to retrieve the content of a specific CMS page. The following query returns information about the “404 Not Found” CMS page:

{
  cmsPage(identifier: "no-route") {
    identifier
    url_key
    title
    content
    content_heading
    page_layout
    meta_title
    meta_description
    meta_keywords
  }
}

Output:

{
  "data": {
    "cmsPage": {
      "title": "404 Not Found",
      "url_key": "no-route",
      "content_heading": "Whoops, our bad...",
      "content": "<dl>\r\n<dt>The page you requested was not found, and we have a fine guess why.</dt>\r\n<dd>\r\n<ul class=\"disc\">\r\n<li>If you typed the URL directly, please make sure the spelling is correct.</li>\r\n<li>If you clicked on a link to get here, the link is outdated.</li>\r\n</ul></dd>\r\n</dl>\r\n<dl>\r\n<dt>What can you do?</dt>\r\n<dd>Have no fear, help is near! There are many ways you can get back on track with Magento Store.</dd>\r\n<dd>\r\n<ul class=\"disc\">\r\n<li><a href=\"#\" onclick=\"history.go(-1); return false;\">Go back</a> to the previous page.</li>\r\n<li>Use the search bar at the top of the page to search for your products.</li>\r\n<li>Follow these links to get you back on track!<br /><a href=\"http://domain.com/\">Store Home</a> <span class=\"separator\">|</span> <a href=\"http://domain.com/customer/account/\">My Account</a></li></ul></dd></dl>\r\n",
      "page_layout": "2columns-right",
      "meta_title": null,
      "meta_keywords": "Page keywords",
      "meta_description": "Page description"
    }
  }
}

In above output you can see all the details about “404 Not Found” CMSPage.


You can use ChromeiQL tool to test and run GraphQL Query in Magento 2.

How to Get CMS Page Information Using GraphQL in Magento 2 Click To Tweet

If you liked this tutorial, then please subscribe to our Newsletter for Magento tutorials. You can also find us on Twitter and Facebook. If you have any problem or would like to add to the discussion, leave a comment below!

You May Also Like

Editorial Staff

About the Author: Editorial Staff

Editorial Staff at the MageBeginners is a team of Magento experts writing about Magento Tutorials, Themes, Extensions, Guides, Tricks and much more...

Leave a Reply

Your email address will not be published. Required fields are marked *