If you’re exploring GraphQL in Magento 2, Postman is a powerful tool to help you test queries and mutations quickly — no browser extensions needed. Just Use Postman to Run GraphQL.
But there’s a catch: many developers get tripped up by syntax errors or formatting issues when sending requests. In this post, we’ll walk you through the correct way to use Postman for both queries and mutations in Magento 2.
How to Use Postman to Run GraphQL Queries in Magento 2
🔧 First, Set Up Your Postman Request
- Method: 
POST - URL: 
https://your-magento-site.com/graphql - Headers:
Content-Type: application/json- (Optional) 
Authorization: Bearer <your-access-token>for protected endpoints 
 
✅ Option 1: Using JSON Format with Variables (Recommended)
This is the most flexible and powerful approach. You can define your query and send dynamic values through variables.
✏️ Example: Mutation with Variables
{
  "query": "mutation AddCustomRecord($input: CustomRecordInput!) { addCustomRecord(input: $input) { id first_name last_name } }",
  "variables": {
    "input": {
      "first_name": "SB",
      "last_name": "DevBlog"
    }
  }
}
⏳ You can reuse this same body with different values, making it perfect for testing dynamic mutations.
✅ Option 2: Using GraphQL Body (No Variables)
Postman also supports sending GraphQL directly. To do this:
- Change the Body type to 
GraphQL - Paste your mutation/query directly
 
✏️ Example: Inline Mutation
mutation {
  addCustomRecord(input: { first_name: "Ali", last_name: "Khan" }) {
    id
    first_name
    last_name
  }
}
📝 This is great for quick testing — but doesn’t support variables.
⚠️ Common Mistake to Avoid  to Use Postman to Run GraphQL Queries  in Magento 2
Many developers try this:
{
  "query": "{ products(filter: { sku: { eq: \"24-MB01\" } }) { items { id name sku } } }"
}
And wonder why they see errors like:
"Syntax Error: Expected Name, found String \"query\""✅ This only works if headers and format are exactly right. Instead, stick to the structured JSON format or use the GraphQL body mode.
🧠 Pro Tips
- Always use 
POSTmethod, even forqueries - Double-check your header: 
Content-Type: application/json - Use the GraphQL body for simple queries or JSON body with variables for complex ones
 - Install tools like Altair if you want a browser-based playground
 
📌 Coming Up Next
In the next part of our Magento 2 GraphQL series, we’ll learn Magento 2 Default GraphQL Queries — starting from scratch and hooking into your own database tables
🔗 Want to stay ahead in GraphQL + Magento? Follow along at SB Dev Blog and level up your Magento development game.
