Magento 2 How to get CMS Block in GraphQL

All developers know that CMS Blocks can be used to display promotional banners, sale blocks, return policies, or important information messages on some sections of the store, etc. In this tutorial, we'll discuss how to get CMSBlocks in GraphQL. The CMSBlocks query returns information about blocks.


  • Get only one CMSBlock

    cmsBlocks(identifiers: String): CmsBlocks
  • Get multiple CMSBlock

    cmsBlocks(identifiers: [String,String]): CmsBlocks

The following query returns information about "Login Data" CMSBlock.


{ cmsBlocks(identifiers: "login-data") { items { identifier title content } } }


{ "data": { "cmsBlocks": { "items": [ { "identifier": "login-data", "title": "Login Info Block", "content": "<div class=\"message info\" style=\"margin-top: 50px;\">\n <p><strong>Try Demo Customer Access</strong></p>\n <p><span style=\"display:inline-block; width: 80px; padding-right: 10px;\">Email:</span></p>\n <p><span style=\"display:inline-block; width: 80px; padding-right: 10px;\">Password:</span></p>\n</div>" } ] } } }

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.

Recent Articles
Chrome Extension
Copyright © 2024 All rights reserved.
Ads OFF toggle_off