Magento 2 How to get CMS Page in GraphQL

We all know that CMS Pages are set from the backend, the page is created by text, images, block of content, variables, and frontend. And we will explain to you how to get this CMSPage using GraphQL. The CMSPage query returns information about content pages.

Syntax

cmsPage(identifier: String): CmsPage

The following query returns information about "404 Not Found" CMSPage.

Request

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

Response

saveCopyzoom_out_map
{ "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" } } }

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
Tags
Newsletter
Chrome Extension
Copyright © 2024 devhooks.in All rights reserved.
Ads OFF toggle_off
wifi_off