GraphQL

Fetch order data from Shopify using GraphQL queries with metafields and metaobjects.

GraphQL in Pixi

Pixi uses GraphQL to fetch order data from Shopify. The Query tab provides autocomplete and validation to help you build queries efficiently. Modify fields inside the order node to customize what data is available in your templates.

For complete field references, see:

Query Structure

The query wrapper is fixed—you only edit fields inside the order node. Pixi provides a comprehensive base query that covers most use cases:

query GetOrder($id: ID!) {
  order(id: $id) {
    # Your fields here
  }
}

Common Fields

Order Information

order(id: $id) {
  name
  email
  phone
  note
  createdAt
  fullyPaid
  statusPageUrl
  presentmentCurrencyCode
  currencyCode
  taxesIncluded
  paymentGatewayNames
  discountCodes
}

Financial Data

All price fields return MoneyBag objects with both shop and customer currency:

order(id: $id) {
  totalPriceSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
  subtotalPriceSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
  totalTaxSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
  totalDiscountsSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
  totalShippingPriceSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
  totalRefundedSet {
    presentmentMoney { amount currencyCode }
    shopMoney { amount currencyCode }
  }
}

Line Items

lineItems(first: 100) {
  nodes {
    id
    title
    variantTitle
    quantity
    sku
    image { url }
    
    # Pricing
    originalUnitPriceSet {
      presentmentMoney { amount currencyCode }
      shopMoney { amount currencyCode }
    }
    discountedTotalSet {
      presentmentMoney { amount currencyCode }
      shopMoney { amount currencyCode }
    }
    
    # Tax information
    taxLines {
      title
      rate
      ratePercentage
      priceSet {
        presentmentMoney { amount currencyCode }
        shopMoney { amount currencyCode }
      }
    }
    
    # Product/Variant data
    variant {
      id
      barcode
      compareAtPrice
      price
    }
  }
}

Addresses

billingAddress {
  name
  firstName
  lastName
  company
  address1
  address2
  city
  province
  provinceCode
  country
  countryCodeV2
  zip
  phone
}
shippingAddress {
  # Same fields as billingAddress
}

Fulfillment & Tracking

fulfillments {
  trackingInfo {
    company
    number
    url
  }
}
shippingLine {
  title
}

Metafields

Access custom data stored on orders, products, or variants.

Order Metafields

order(id: $id) {
  metafields(first: 20) {
    edges {
      node {
        namespace
        key
        value
        type
      }
    }
  }
}

Product/Variant Metafields

Access specific metafields by namespace and key:

lineItems(first: 100) {
  nodes {
    product {
      dimensions: metafield(namespace: "custom", key: "dimensions") {
        value
        type
      }
      customData: metafield(namespace: "custom", key: "product_info") {
        value
      }
    }
    variant {
      size: metafield(namespace: "custom", key: "size") {
        value
      }
    }
  }
}

Metaobjects

Fetch structured data from metaobject references:

Single Reference

product {
  color: metafield(namespace: "shopify", key: "color") {
    value
    reference {
      ... on Metaobject {
        id
        handle
        type
        displayName
      }
    }
  }
}

Multiple References

product {
  materials: metafield(namespace: "custom", key: "materials") {
    value
    references(first: 10) {
      nodes {
        ... on Metaobject {
          id
          handle
          type
          displayName
        }
      }
    }
  }
}

Advanced Example

Complete query with metafields and metaobjects:

order(id: $id) {
  name
  lineItems(first: 50) {
    nodes {
      title
      quantity
      product {
        vendor
        dimensions: metafield(namespace: "custom", key: "dimensions") {
          value
        }
        medium: metafield(namespace: "custom", key: "painting-medium") {
          value
          references(first: 10) {
            nodes {
              ... on Metaobject {
                id
                handle
                type
                displayName
              }
            }
          }
        }
      }
    }
  }
}

Using in Liquid

{% for item in order.lineItems.nodes %}
  <div class="item">
    <h3>{{ item.title }}</h3>
    
    {% if item.product.dimensions %}
      <p>Dimensions: {{ item.product.dimensions.value }}</p>
    {% endif %}
    
    {% if item.product.medium %}
      <p>Medium: 
      {% for medium in item.product.medium.references.nodes %}
        {{ medium.displayName }}{% unless forloop.last %}, {% endunless %}
      {% endfor %}
      </p>
    {% endif %}
  </div>
{% endfor %}

Tips

  • Use pagination (first: 100) for collections to control query size
  • All price fields return MoneyBag objects—use the money filter for automatic formatting
  • Test queries with different order types (fulfilled, partial, refunded)
  • The Query tab provides autocomplete—use it to discover available fields
  • Only fetch fields you'll use in templates for better performance