Skip to content
Build
Markdown

Call Shopify

Use Shopify’s GraphQL API directly, with credentials held by Littleworks.

One GraphQL client

Inside a work, use await shopify.graphql(query, variables). Littleworks manages the store’s connection and credentials. The result is Shopify’s raw GraphQL envelope, including data, errors, and extensions when present.

Client interface
const result = await shopify.graphql(query, variables);

if (result.errors?.length) {
  throw new Error("Shopify could not complete the request");
}

return result.data;

The snippet assumes you have defined a query and its variables for your task. Use Shopify’s Admin GraphQL reference for operation-specific fields and required access scopes. Mutations may also return operation-specific userErrors inside data; inspect those too.

Declare permission explicitly

Set permissions.shopify to true in the manifest. This enables the client for the work; it does not grant new Shopify scopes. The store installation’s approved scopes remain the outer limit. Read get_context to see those scopes before planning an operation.

Manifest permission
{
  "permissions": { "shopify": true }
}

The current development app requests read_products and read_orders. Do not assume a work can update products, edit themes, or access all customer data. Some operations also depend on Shopify’s protected-data requirements and order-access limits.

Preview is not a Shopify sandbox

Preview separates Littleworks documents from Live documents. It uses the same Shopify connection. Read-only checks are useful for testing; mutations, when permitted, affect the real store.

Handle failures deliberately

A work may have already changed a document or completed a Shopify operation before a later error. Check the run and the affected state before retrying. Littleworks does not promise exactly-once external effects or transactions spanning storage and Shopify.

Keep logs operational. Do not log customer payloads, credentials, or full GraphQL responses containing personal data. See Inspect and troubleshoot.