Did you try to use Magento 2 Default GraphQL? Magento 2 comes packed with a powerful set of out-of-the-box GraphQL queries that let you retrieve almost any information you need — from products and categories to CMS content and customer data.
In this post, we’ll break down the most common default GraphQL queries available in Magento 2 and show you how to use them effectively for building headless stores, mobile apps, or custom storefronts.
Magento 2 Default GraphQL Queries Explained
🛒 1. Product Queries
You can use the products
query to retrieve information about one or more products.
Use Post method with graphql endpoint:
https://yourdomain.com/graphql
Query:
{
products(filter: { sku: { eq: "prodsku" } }) {
items {
id
name
sku
description {
html
}
price_range {
minimum_price {
regular_price {
value
currency
}
}
}
}
}
}
Response
{
"data": {
"products": {
"items": [
{
"id": 123,
"name": "Product Name",
"sku": "prodsku",
"description": {
"html": ""
},
"price_range": {
"minimum_price": {
"regular_price": {
"value": 1075,
"currency": "USD"
}
}
}
}
]
}
}
}
This is super helpful when building product detail pages or custom PLPs.
📂 2. Category Queries
Use the category
query to fetch details about a specific category.
Query:
{
category(id: 3) {
id
name
description
products {
items {
name
sku
}
}
}
}
Response:
{
"data": {
"category": {
"id": 3,
"name": "Category",
"description": null,
"products": {
"items": [
{
"name": "Product One",
"sku": "prodonesku"
},
{
"name": "Product Two",
"sku": "productwosku"
}
]
}
}
}
}
📄 3. CMS Page Queries
Need to load static content like About Us or Terms & Conditions? Use the cmsPage
query.
Query:
🔍 Example: Get CMS Page by URL Key
{
cmsPage(identifier: "about-us") {
title
content
content_heading
}
}
Response:
{
"data": {
"cmsPage": {
"title": "About Us",
"content": "About Us Content",
"content_heading": ""
}
}
}
👤 4. Customer Info (Authenticated)
If a user is logged in (you’ll need a bearer token), you can fetch their details with customer
.
{
customer {
firstname
lastname
email
}
}
Response:
{
"data": {
"customer": {
"firstname": "SB",
"lastname": "DEV",
"email": "info@sbdevblog.com"
}
}
}
📦 5. Cart and Checkout Queries
Want to build a custom cart or checkout? Magento gives you GraphQL endpoints to:
- Create carts
- Add products
- Update quantities
- Retrieve totals
There are a lot of queries/mutations here, but here’s a small preview:
🔍 Example: Create Empty Cart
mutation {
createEmptyCart
}
Response:
{
"data": {
"createEmptyCart": "OiU8hu6Ks3jIMU2fMJg1R8KkpSaaMLlL"
}
}
🔍 Example: Add Product to Cart
mutation {
addSimpleProductsToCart(
input: {
cart_id: "your_cart_id"
cart_items: [
{
data: {
sku: "sku"
qty: 1
}
}
]
}
) {
cart {
items {
product {
name
}
quantity
}
}
}
}
Response:
{
"data": {
"addSimpleProductsToCart": {
"cart": {
"items": [
{
"id": "1",
"product": {
"name": "Product Name",
"sku": "sku"
},
"quantity": 1
}
]
}
}
}
}
This makes building custom carts and mobile apps much easier.
💡 Wrapping Up
Magento 2’s default GraphQL queries are incredibly powerful and flexible. Whether you’re building a PWA, mobile app, or integrating with another platform, these APIs give you fast and structured access to your store data.
In our next blog, we’ll go learn How to Get Bearer Token in Magento 2.
➡️ Stay tuned and follow SB Dev Blog for hands-on Magento tutorials!
Got any specific queries you’d like explained? Drop your questions in the comments — we’d love to hear from you!