metafields in webhook filtering includeFields
I've added my metafields to the includeFields so I can filter for them like so:
But now I can see the fields are no longer registered when viewing the schema (attached).
Docs mention that all fields to be filtered must be in the includeFields array, but this appears to have deregistered it in schema. What have I done wrong?

34 Replies
removing all includeFields, seems to allow gadget to register the namespace as normal, however the filter does not seem to work as expected - no webhooks get through it that should be passing.
Do you mind sharing the app url? Then I can take a look at what might be the issue
Let me change branches first, one moment.
I can't seem to get any of the webhook filter changes to update now - hmm
I'm not personally having issues but I've only just set the filter and includes fields
Gonna test now
I got an update


This was 2 changes. Changed from null to
test 1
to test 2


It looks like my webhook payload is the full payload though
My case is slightly different with metafields on the Variant, so not sure if that is where the issue comes in
also with an app namespace included
I'm not able to get the filters or include fields to register at all right now - so not sure if my app is bugged now?

Is that the correct syntax for app owned metafeilds in filters?
According to the Shopify dev assistant, it is. I wasn't able to find specific examples in docs anywhere.
I wonder if its $app-namespace.key
Or even just $app:namespace like how you define it
$app:namespace
was definitely incorrect as the call would come back with an error from Shopify. Can't the :
apparently.
trying the - nowFor variants, I think that its correct the way you put it

Shopify really needs to improve their docs
registering this in the includeFields
"variants.metafields.$app-my-app.key1",
Causes the gadget registration to flag as not registered, and also the metafields don't come through on the webhook - so I don't believe that's it.
Shopify really needs to improve their docsI wasn't sure registering metafield based filters was something on your end or their end because of this. Shopify dev assistant seemed to be pretty sure on the syntax but had no references... haha. Not mentioned in the gadget docs either.
It looks like I was actually wrong. My filters aren't working
I've also tried using the rationalised namespace in the filter (with the app id), and that doesn't work either. Maybe this is not actually supported by Shopify?
Take a look at this: https://community.shopify.dev/t/webhook-filter-by-metafield/17301/2
Shopify Developer Community Forums
Webhook filter by metafield
Ok so it turns out it does work! You need to set includeFields and include metafields within it. I was doing this, but where it was going wrong is that I was setting includeFields to a small set for testing - i.e. id, metafields, status. Then to try to fire the webhook, I was updating the product title. Shopify wasn’t firing the webhook as n...
I'm about to test it myself
This appears to be working (but its the end of a long day, so I could be hallucinating).
Its super weird that metafields are sent regardless of change
I've left includeFields empty for now
Is it working for you?
I just want to make sure that you don't get webhooks that you don't want
It looks like the filter above works so we only get webhooks that fulfill the filter. It doesn't look like includeFields works, even when using the rationalised namespace - maybe there's something wrong there.
Gadget also doesn't recognise the field as registered when using the rationalised namespace
So i'll have to test more
The filter is the bigger win at least. includeFields and getting rid of updated_at is just a bonus
Thanks for your help - really appreciate it!
Some shortfalls I'd love your help with when you're next available please Antoine.
1. Gadget can't do variables in the shopifyFilter. Given we need to use the rationalised namespace with the app id - when setting the shopifyFilter to a variable or using literals so we can conditionally set the app id based on an env variable - gadget doesn't think it's valid:
"options" is not a valid object
2. Using a Shopify Filter with rationalised namespace causes Gadget to think the app namespace is no longer registered in the field schema UI (even though the webhook registration call to shopify shows the app namespace being registered)
3. I still haven't found a way to use the rationalised namespace or app namespace in the includedFields that Gadget likes. I'm thinking this is just a shortfall currently?
I'd love to go live with these webhook filters but am concerned the above means something actually isn't correct.Hi Anthony, could you provide some more context/steps to reproduce the issues you're seeing? What does "rationalised namespace" refer to? From where do you see
"options" is not a valid object
?All of our metafields use app reserved namespaces, so they are registered as
$app:our_namespace
In webhooks and in Shopify, this rationalises out to replace the $app, with our app id eg app--123456789--our_namespace
When trying to apply the webhook filters in the action files in Gadget, after much testing, it only works if we apply the filter as the rationalised namespace ie. app--123456789--our_namespace
instead of $app:our_namespace
. It looks like this might just be a Shopify limitation.
The filter below works as expected:
shopifyFilter: "variants.metafields.key:my_settings AND variants.metafields.namespace:app--123456789--our_namespace AND variants.metafields.value:*",
However, given the app id is specific to the environment - Id like to use a variable here so when we deploy, it works as expected and uses the production app id.
Using either of these options does not work and makes Gadget show a global error in the 'problems'/ terminal area in the editor.
or this:
I can send through a Loom as a DM of the actual issue in our app environment if preferred?Got it, thanks for the additional context! Will take a look into this for you. A Loom would be helpful to make sure I'm seeing the same thing as you're referring to also!
So after some investigation I can tell you two things:
1. Shopify themselves don't support webhook filters using the
$app:namespace
shorthand: https://community.shopify.dev/t/is-there-a-way-to-use-app-in-filter/6123
2. The shopifyFilter
in the options
actions object must be static, as it's evaluated at buildtime not runtime. So passing variables in it will not work
Unfortunately the only way I can think of to make this work right now would be to hardcode the string filter for the production app, deploy to your production environment, and change it back to point to your development app in your development environment. Definitely not ideal(sorry!) and hopefully Shopify can support the $app:namespace
metafield shorthand soon!Thanks so much for that info Jenny - I really appreciate it.
What about using the metafield inside the
includeFields
? I'd like to optimise the includeFields too, but if I add the rationalised metafield there, Gadget doesn't consider the metafield as registered (because the field in the schema is set up to use the $app:namespace
?No problem! And I'm not sure exactly why you need the rationalized metafield in the
includeFields
- if you have metafields on your model Gadget registers your webhook subscriptions with the metafield namespaces included. I'm also not sure if you can even specify $app:namespace
in the includeFields
-it would be strange that Shopify supports that and not in the filter itself 🤔
From this post Anotine shared earlier: https://community.shopify.dev/t/webhook-filter-by-metafield/17301/2
Thanks Jenny. Appreciate the info and help.
Glad it helps! 🙂