Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: Does the PRODUCTS_UPDATE graphql webhook only trigger when fields in includeFields have changed?

Does the PRODUCTS_UPDATE graphql webhook only trigger when fields in includeFields have changed?

Kalen_Jordan
Shopify Partner
779 36 141

Trying to determine if the includedFields in webhook subscription control whether webhooks fire only for those fields changing (on an a product update trigger for example).

 

From some tests I've done, I'm definitely seeing that to be the case, but not consistently.

 

I have A set up with includedFields = tags, B with title, body_html, and C with price.

 

I think price was probably an invalid field to use since it's on the variant.

 

When I change a tag and save, only A fires.

 

Changing price caused B and C to fire.

 

Changing body content causes only B to fire.

Replies 4 (4)

Liam
Community Manager
3108 344 889

Hi Kalen,

 

Thanks for flagging this - it does appear to be the case that webhooks will fire only for those fields which are specified - as you've found, and it's important to note that the payload of the webhook will still include the entire record, not just the fields specified in includeFields. I've gotten in touch with the events product team to confirm this and to look at the inconsistencies you've highlighted, and determine if the docs should be updated to clarify the behaviour you've noted. 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Kalen_Jordan
Shopify Partner
779 36 141

Nice! Thanks man!

Kalen_Jordan
Shopify Partner
779 36 141

Hey Liam - do you know which fields it looks at? Have done some tests with title, tags that have worked. But I tried publishedOnPublication and it didn't seem to work.

baggio_giacomo
Shopify Partner
20 0 2

Hi there! I'm trying to filter my webhooks too but I'm getting some strange behaviours.

Here's my .toml file containing the config:

...

[[webhooks.subscriptions]]
  topics = [ "products/update" ]
  uri = "/webhooks"
  include_fields = [ "id", "admin_graphql_api_id", "variants.price" ]

...

 

I correctly receive only those 3 fields but the webhooks are triggered when updating every product/variant property (e.g: Webhook is triggered if a variant metafield is updated).

 

If this isn't the proper way to do it, how can I make the products/update webhook to trigger only when the variant price is updated? 

I have a bulk mutation that updates every variant, I cannot receive thousands and thousands of useless webhooks, it is a waste of resources (for both of us)