Infinite Webhook and graphql on node js

YaroslavErimish
Visitor
1 0 0
Hello, 
1. Can You explain please me how avoid infinity webhook, i need to use product-update webhook and then when i will catch this one i will send post request to my shop and again update other field for example, therefore it will trigger again update-product hook. So i need to resolve this, can you explain please.
2. When I create product, triggered two hooks, update -first and create- second, why?
3. How to use GraphQL when handle hook and send request to the shop? Because i can't find You docs about it.
Reply 1 (1)
c10s
Shopify Partner
67 12 21

For your first question, this can be avoided by checking what data changed and updating Shopify only if you need to.

One way I've dealt this in the past is to store a json object of state that I care about (eg. price and inventory) in a product metafield. Then when I receive a product update webhook I first fetch this metafield (via the Admin API) and compare it against the webhook payload. If they don't match then I update Shopify (and the metafield) otherwise I do nothing.