How to Get CMS Block Information Using GraphQL in Magento 2

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

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

Let’s start!

Get CMS Page Query:

The {cmsBlocks} query can returns CMS block information. Here you must include the CMS block identifier value to retrieve the content of a specific CMS block.

{
  cmsBlocks(identifiers: "footer_links_block") {
    items {
      identifier
      title
      content
    }
  }
}

Output:

{
  "data": {
    "cmsBlocks": {
      "items": [
        {
          "identifier": "footer_links_block",
          "title": "Footer Links Block",
          "content": "<ul class=\"footer links\">\n    <li class=\"nav item\"><a href=\"https://www.yourstore.com/about-us/\">About us</a></li>\n    <li class=\"nav item\"><a href=\"https://www.yourstore.comcustomer-service/\">Customer Service</a></li>\n</ul>\n"
        }
      ]
    }
  }
}

The following query returns information about the “footer_links_block” CMS block: If you need to get multiple CMS blocks you can pass identifiers comma separated like:- “footer_links_block, contact-us-info”


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

.

How to Get CMS Block 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 *