# Shopify GraphQL recipes

> Copy-ready Shopify GraphQL queries and mutations for the Admin and Storefront API, validated against version 2026-10, with variables and scopes.

Page: https://lintelagency.com/resources/graphql

These are copy-ready GraphQL documents for Shopify’s Admin and Storefront APIs, version 2026-10. Each page has the query or mutation, example variables, the access scopes it needs and what the response looks like. Every document and its variables are validated against Shopify’s published schema before we publish. The REST Admin API is legacy, so new apps should use these GraphQL calls.

- Validated against the Admin or Storefront API schema for version 2026-10 on the date shown. Check the version in your request URL.
- IDs and store addresses in the examples are placeholders. Replace them with your own.
- Admin API calls need an access token from your app. Never put an Admin API token in a storefront or theme.
- MIT license. Use the code in your own store or in client work.

## Bulk operations

- [Export all products with a bulk operation](https://lintelagency.com/resources/graphql/bulk-export-products): Export every Shopify product and variant to a JSONL file with bulkOperationRunQuery, then poll the operation and download the result.
- [Export orders for a date range with a bulk operation](https://lintelagency.com/resources/graphql/bulk-export-orders-by-date): Export every Shopify order in a date range, with line items, to a JSONL file using bulkOperationRunQuery and an orders search filter.
- [Import data with a staged upload and bulkOperationRunMutation](https://lintelagency.com/resources/graphql/bulk-import-with-staged-upload): Run one mutation thousands of times: upload a JSONL file of variables with stagedUploadsCreate, then start bulkOperationRunMutation.

## Metafields and metaobjects

- [Write metafields with metafieldsSet](https://lintelagency.com/resources/graphql/metafields-set): Create or update up to 25 metafields on any resource in one atomic call with metafieldsSet, with compareDigest to avoid overwriting newer values.
- [Create a metafield definition](https://lintelagency.com/resources/graphql/create-metafield-definition): Create a typed, validated metafield definition with metafieldDefinitionCreate, pin it in the admin and expose it to the Storefront API.
- [Create a metaobject definition and upsert entries](https://lintelagency.com/resources/graphql/metaobject-definition-and-upsert): Model a size chart as a metaobject: create the definition with metaobjectDefinitionCreate, then create or update entries by handle with metaobjectUpsert.

## Products and inventory

- [Create or update a whole product with productSet](https://lintelagency.com/resources/graphql/product-set): Sync a product from an external system in one call: productSet creates or updates the product, its options and variants, matched by handle.
- [Create and update many variants at once](https://lintelagency.com/resources/graphql/bulk-create-update-variants): Add new sizes or colors with productVariantsBulkCreate and change prices on many variants with productVariantsBulkUpdate, one product per call.
- [Set stock levels from an external system](https://lintelagency.com/resources/graphql/set-inventory-quantities): Overwrite available stock per item and location with inventorySetQuantities, using changeFromQuantity and an idempotency key as 2026-10 requires.
- [Read stock levels by location](https://lintelagency.com/resources/graphql/inventory-levels-by-location): Read available, on hand, committed and incoming stock for every item at a location, or for one item across all locations.
- [Group products into a combined listing](https://lintelagency.com/resources/graphql/combined-listings-update): Show separate color products as one listing: create a parent product, then attach the children and their option values with combinedListingUpdate.

## Discounts and Functions

- [Turn on a discount Function as an automatic discount](https://lintelagency.com/resources/graphql/function-backed-automatic-discount): Activate your discount Function in a store with discountAutomaticAppCreate: function handle, discount classes, combinations and a JSON config metafield.
- [Add discount codes in bulk](https://lintelagency.com/resources/graphql/bulk-discount-codes): Add up to 250 unique codes per call to an existing code discount with discountRedeemCodeBulkAdd, then check which codes were imported.
- [Activate a delivery, payment or validation Function](https://lintelagency.com/resources/graphql/register-function-customization): Turn on a deployed Function in a store with deliveryCustomizationCreate, paymentCustomizationCreate or validationCreate, with its settings as a metafield.

## Orders and customers

- [Edit an order after it was placed](https://lintelagency.com/resources/graphql/order-editing): Add items, change quantities and commit the change with orderEditBegin, orderEditAddVariant, orderEditSetQuantity and orderEditCommit.
- [Create a draft order with custom prices](https://lintelagency.com/resources/graphql/draft-order-custom-price): Create a quote or B2B order with draftOrderCreate: override a variant’s price with priceOverride and add custom line items with their own price.
- [Fulfill an order with a tracking number](https://lintelagency.com/resources/graphql/fulfillment-with-tracking): Read the open fulfillment orders of an order, then create a fulfillment with carrier, tracking number and URL using fulfillmentCreate.
- [Refund an order](https://lintelagency.com/resources/graphql/refund-order): Calculate a refund with suggestedRefund, then refund line items, restock them and return the money with refundCreate and an idempotency key.
- [Add tags to orders, customers or products in bulk](https://lintelagency.com/resources/graphql/bulk-add-tags): Tag one resource with tagsAdd without overwriting its tags, or thousands at once by running tagsAdd in a bulk mutation operation.
- [List the customers in a segment](https://lintelagency.com/resources/graphql/customer-segment-members): Page through the members of a customer segment with customerSegmentMembers, or run an ad hoc segment query with customerSegmentMembersQueryCreate.
- [Translate content, also per market](https://lintelagency.com/resources/graphql/translations-register): Read a resource’s translatable content and digests with translatableResource, then save translations, optionally for one market, with translationsRegister.

## Webhooks

- [Subscribe to a webhook with a filter](https://lintelagency.com/resources/graphql/webhook-subscription-with-filter): Only receive the webhooks you need: create a subscription with webhookSubscriptionCreate and a filter in Shopify search syntax, or in shopify.app.toml.

## Storefront API

- [Create a cart and add items with the Storefront API](https://lintelagency.com/resources/graphql/storefront-cart-create-and-add): Build a headless cart: cartCreate with lines and buyer country, cartLinesAdd for more items, and checkoutUrl to send the buyer to checkout.
- [Show local prices and languages with @inContext](https://lintelagency.com/resources/graphql/storefront-local-prices-in-context): Get prices in the buyer’s currency and content in their language from the Storefront API by adding @inContext(country, language) to the query.
- [Read metafields and metaobjects with the Storefront API](https://lintelagency.com/resources/graphql/storefront-metafields-and-metaobjects): Read a product’s metafields, follow a metaobject reference such as a size chart, and list all metaobjects of a type like FAQs.

## Basics

- [Read query cost and throttle status](https://lintelagency.com/resources/graphql/query-cost-and-throttle-status): Every Admin API response reports its cost and the remaining bucket in extensions.cost. Use it to pace requests and handle THROTTLED errors.
- [Page through results with cursors](https://lintelagency.com/resources/graphql/cursor-pagination): Read every product, order or customer page by page: ask for pageInfo, pass endCursor as after, and stop when hasNextPage is false.

## Questions

### Is the Shopify REST Admin API deprecated?

Shopify calls it legacy since October 2024, and new public apps have had to use GraphQL since April 2025. Shopify has not announced a date to switch REST off entirely. Each recipe here names the REST call it replaces.

### Where can I run these queries?

In the GraphiQL app for your store, in your app’s code with an access token, or with the Shopify CLI. Storefront API queries also run from a browser with a public Storefront token.

### Which API version do the recipes use?

Version 2026-10, the latest stable version on the date each page was checked. Most documents also work on the versions before and after it; the page notes any field that changed.
