@kevinhughes27
Any thoughts on maybe filtering webhooks arguments down somehow? I'm not sure what the right pattern for this so let me describe the problem:
The payload for a product update webhook is the whole product, including variants, and all other metadata. This isn't a small chunk of data.
Now lets say I have a customer with 1000 products (this is a mean sized customer for this webhook). If they do a bulk update, I'm now going to get 1000 jobs into resque for this one customer.
One thing that became apparent this past BFCM is that a lot of people were doing a lot of bulk updates of things, and my redis got fucked. I solved the problem by monkey patching webhook controller to only send the product id as a parameter to the job. This works but is not nice.
I'm thinking maybe it would make sense to have some kind of mechanism/hook/whatever that lets you trim the payload.
My best idea is adding a whitelist of parameters to config.webhooks in the shopify_app initializer. Then we apply this whitelist to the webhook hash before sending to resque.
thoughts?
IIRC Shopify has a mechanism for specifying what fields you want in the webhook. I've never actually used this so I am not sure if it works with ShopifyApp out of the box but I think we should investigate that solution before going to a manual whitelisting.
AFAIK we don't have any mechanism for filtering fields on webhooks at the moment
see the fields property https://help.shopify.com/api/reference/webhook
@kevinhughes27 oh dang didn't even notice that. definitely should be included into the webhook definition
All you have to do is include fields in your webhooks config. You can also include namespaces of metafields you want. I'm not sure if you get all metafield info in your webhooks by default, or only if you specify the namespaces.
ShopifyApp.configure do |config|
config.webhooks = [
{
topic: 'products/update',
address: 'https://example-app.com/webhooks/products_update',
fields: 'id,type,title,options,variants',
metafield_namespaces: ["google", "inventory"]
}
]
end
Edit: Correct metafield namespace info.
see the fields property https://help.shopify.com/api/reference/webhook
Would be helpful to have this in the Webhooks section of the README.
PR it up :heart:!
I read that as "PR is up" and thought, damn Kevin is on fire today.
don't disappoint me @kevinhughes27!
Fixed in https://github.com/Shopify/shopify_app/pull/362 :)
Most helpful comment
see the fields property https://help.shopify.com/api/reference/webhook