I recently worked on a project that required implementing a Product Tag Picker within a Shopify app. Since Shopify does not currently provide a built-in Resource Picker for productTags, I wanted to share the approach I used to achieve this functionality.
Objective
The goal was to create a user interface that allows merchants to:
- Search and select one or more product tags.
- Display selected tags for review or removal.
- Use the selected tags to filter products dynamically.
Step 1: Fetch Product Tags Using GraphQL
The Shopify Admin GraphQL API provides access to product tags through the productTags field.
The following query retrieves available product tags:
{
productTags(first: 10) {
edges {
node
}
}
}
Pagination can be implemented using the after argument to load additional tags as required.
Note: The productTags field is available in the Admin API, not the Storefront API. It should be accessed using the app’s Admin API token.
Step 2: Retrieve Products by Tag
Once tags are selected, products can be retrieved based on a tag using the following query:
query getProductsByTag($tag: String!) {
products(first: 50, query: $tag) {
edges {
node {
id
title
handle
tags
variants(first: 50) {
edges {
node {
id
title
sku
price
availableForSale
}
}
}
}
}
}
}
Example variable:
{
"tag": "tag:summer"
}
Multiple tags can also be combined:
{
"tag": "tag:summer OR tag:winter"
}
Step 3: Building the User Interface
For the interface, I used the following Shopify Polaris components:
- Autocomplete for searching and selecting tags.
- Tag for displaying and removing selected tags.
This combination provides a consistent, user-friendly experience aligned with Shopify’s design standards.
Summary
Since there is no native picker for productTags, the recommended approach is to:
- Retrieve tags using the
productTagsquery from the Admin API. - Use Polaris
AutocompleteandTagcomponents for selection and display. - Filter products with a query such as
tag:summerusing the Admin API.
This solution offers a clean and efficient method for implementing tag-based product filtering or tag selection features in Shopify applications. I would be interested to hear if other developers have found alternative approaches for managing product tags within app interfaces.