Skip to main content
Shopify Admin GraphQL API for Beginners: Orders, Products & Metafields
All Articles
Technical10 min read

Shopify Admin GraphQL API for Beginners: Orders, Products & Metafields

A practical introduction to the Shopify Admin GraphQL API. Fetch orders, update products, and read/write metafields with real code examples in Node.js.

Storesmith Team

3 June 2026

GraphQLAdmin APINode.jsShopify API

Why GraphQL over REST?

Shopify's GraphQL Admin API lets you request exactly the fields you need in a single round-trip — no over-fetching, no multiple REST calls. It also gives access to newer capabilities like metafield definitions that don't exist in REST.

Authentication

All Admin API calls require an access token in the X-Shopify-Access-Token header:

const SHOPIFY_DOMAIN = "yourstore.myshopify.com";
const ACCESS_TOKEN = process.env.SHOPIFY_ACCESS_TOKEN;

async function shopifyQuery(query, variables = {}) {
  const res = await fetch(
    `https://${SHOPIFY_DOMAIN}/admin/api/2024-07/graphql.json`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "X-Shopify-Access-Token": ACCESS_TOKEN,
      },
      body: JSON.stringify({ query, variables }),
    }
  );
  return res.json();
}

Fetching the last 10 orders

query GetOrders {
  orders(first: 10, sortKey: CREATED_AT, reverse: true) {
    edges {
      node {
        id
        name
        displayFinancialStatus
        totalPriceSet { shopMoney { amount currencyCode } }
        customer { firstName lastName email }
      }
    }
  }
}

Reading a product metafield

query GetProductMeta($id: ID!) {
  product(id: $id) {
    title
    metafield(namespace: "custom", key: "care_instructions") {
      value
      type
    }
  }
}

Writing a metafield

mutation SetMeta($input: [MetafieldsSetInput!]!) {
  metafieldsSet(metafields: $input) {
    metafields { id key value }
    userErrors { field message }
  }
}

Variables:

{
  "input": [{
    "ownerId": "gid://shopify/Product/123456",
    "namespace": "custom",
    "key": "care_instructions",
    "value": "Machine wash cold",
    "type": "single_line_text_field"
  }]
}

Need help implementing this on your store?

Storesmith builds custom Shopify apps and themes. If you'd like expert help with what you just read, we're happy to chat.

Talk to our team