Gatsby: How to trigger build when new Shopify product is created?

Created on 20 Jun 2020  路  2Comments  路  Source: gatsbyjs/gatsby

Summary

What is the suggested method for triggering a new build for a gatsby site hosted on Netlify that's using the Gatsby Source Shopify plugin when a new product is created in Shopify?

Is it a configuration in gatsby or is this done between Shopify and the host (Netlify)?

question or discussion

All 2 comments

Hello @josub
To ensure that you gatsby site is build everytime you make change in your shopify backend, what you need to do is setup a webhook.

Head to netlify dashboard and go to Settings -> Build & Deploy and look for Build Hooks
Build Hooks

And create a build hook, you will get a URL.

Now head over to shopify backend, sorry I haven't used shopify admin but I think you have to find events when you want to trigger a build and add this webhook URL provided by netlify.

Thank you for opening this!

Is it a configuration in gatsby or is this done between Shopify and the host (Netlify)?

This is something you'll need to set up between Shopify and Netlify. As Akash already showed you can get a webhook URL to trigger a build on Netlify. Head to Shopify's community/documentation to find out how to hit that URL. I found this article which suggets:

Copy that and head over back to the Shopify store. Move to Settings > Notifications > Webhooks > Create webhook. For the event, choose Product creation, leave format as JSON and paste the URL from the Netlify build hook and hit Save webhook. Do this again two more times for Product deletion and Product update and any other event you feel may be necessary for a rebuild, while using the same URL from Netlify.
And that is it, as you add/update/delete products, Netlify rebuilds the site in a few minutes to reflect changes.

We're marking this issue as answered and closing it for now but please feel free to comment here if you would like to continue this discussion. We also recommend heading over to our communities if you have questions that are not bug reports or feature requests. We hope we managed to help and thank you for using Gatsby!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

benstr picture benstr  路  3Comments

mikestopcontinues picture mikestopcontinues  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

brandonmp picture brandonmp  路  3Comments

rossPatton picture rossPatton  路  3Comments