Shopify Tasks
These are the docs for Trigger.dev v2 which will be deprecated on January 31st, 2025. You probably want the v3 docs.
Tasks are executed after the job is triggered and are the main building blocks of a job. You can string together as many tasks as you want.
Tasks
All tasks are using Shopify’s REST Resources and can be used with the same general pattern:
Should be a stable and unique cache key inside the run()
. See
resumability for more information.
Resource-specific parameters.
all()
Fetch all resources of a given type.
Returns
An array of Shopify resources.
The PageInfo
object. Will be undefined
if there are no further pages.
count()
Fetch the number of resources of a given type.
Returns
The number of resources.
find()
Fetch a single resource by its ID.
Returns
A Promise
that resolves to the Shopify resource.
save()
Create or update a resource of a given type. The resource will be created if no ID is specified.
Returns
A Promise
that resolves to the Shopify resource.
delete()
Delete an existing resource.
Returns
A Promise
that resolves to undefined
when the resource has been deleted. Throws an error otherwise.
Resources
This is a list of REST Resources that can be used directly as Tasks. They all implement the same methods described above. For resources with non-standard methods, you will have to use the raw Shopify API Client instead - please see the end of this page for further instructions.
- Article
- Blog
- Collect
- Country
- CustomCollection
- Customer
- DiscountCode
- DraftOrder
- Image
- MarketingEvent
- MetaField
- Order
- Page
- PriceRule
- Product
- Redirect
- ScriptTag
- SmartCollection
- Variant
- Webhook
Example usage
In this example we’ll create some products in response to a customer sign-up, count them all before and after, and do a few other things too.
Using the underlying Shopify API Client
You can access the Shopify API Client instance by using the runTask
method on the integration: