storefront

Executes queries against Shopify's Storefront GraphQL API. Works the same way as the graphql tag, but targets the Storefront API instead of the Admin API. The response is stored in a variable for further processing.

The Storefront API provides access to public store data — products, collections, cart operations, and more — without requiring admin-level permissions.

{% storefront query: my_query, variables: my_variables as result %}

{% if result.product %}
  {% log result.product.title %}
{% endif %}

Syntax

{% storefront query: query_string, variables: variables_object as result_variable %}

Parameters

Parameter
Required
Description

query

Yes

Storefront GraphQL query string

variables

No

Object containing variables for the GraphQL operation

Result Object

The result contains the returned data directly accessible at the top level. Query fields are available as properties on the result variable.

If errors occur, they are available in the errors property:

Property
Type
Description

errors

array/null

Array of error objects if the operation failed

Examples

Fetch a product by handle:

List products from a collection:

Fetch product recommendations:

Query with pagination:

Handle errors:

Storefront vs Admin API

Feature

storefront

graphql

API

Storefront GraphQL API

Admin GraphQL API

Access

Public store data

Full admin access

Products

Read-only (public fields)

Read/write (all fields)

Orders

No access

Full access

Customers

No access

Full access

Cart

Yes

No

Use case

Public data, recommendations, availability

Data management, mutations, admin operations

Notes

  • Consumes 1 credit per operation

  • Uses the store's API version configured in DataJet

  • Storefront API errors are automatically logged to the script logs

  • Variables must be a valid object (use json tag to construct complex variables)

  • Result properties are accessed directly (e.g., result.products, not result.data.products)

Last updated