You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With this change, we can register webhooks specifying the filter
parameter that allows to define some conditions on the topic fields
to reduce the number of webhooks received.
Other than adding this feature for already possible registrations, this
extends the number of webhooks that can be registered with this library.
In fact, there are some webhook registrations that require the filter
parameter to be passed to allow the registrationi (this is partly an
assumption because I couldn't find proper documentation around this
topic). An example is METAOBJECTS_CREATE, which, without the filter
param set,
```
mutation webhookSubscriptionCreate($topic: WebhookSubscriptionTopic!, $webhookSubscription: WebhookSubscriptionInput!) {
webhookSubscriptionCreate(topic: $topic, webhookSubscription: $webhookSubscription) {
webhookSubscription {
topic
filter
}
userErrors {
field
message
}
}
}
{
"topic": "METAOBJECTS_CREATE",
"webhookSubscription": {
"callbackUrl": "https://test5.com"
}
}
```
gives the following error:
```
{
"data": {
"webhookSubscriptionCreate": {
"webhookSubscription": null,
"userErrors": [
{
"field": [
"webhookSubscription"
],
"message": "The specified filter is invalid, please ensure you specify the field(s) you wish to filter on."
}
]
}
}
}
```
While with the filter on, works as expected.
---
This change has been made available to 2024-07 and 2024-10, which are
the versions with the filter parameter available, according to the
GraphQL documentation.
---
Refs:
- https://shopify.dev/docs/apps/build/webhooks/customize/filters
- https://shopify.dev/docs/api/admin-graphql/2024-07/input-objects/WebhookSubscriptionInput
- https://shopify.dev/docs/api/admin-graphql/2024-10/input-objects/WebhookSubscriptionInput
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
Note: For changes to the API, see https://shopify.dev/changelog?filter=api
4
4
## Unreleased
5
5
6
+
-[#1347](https://github.com/Shopify/shopify-api-ruby/pull/1347) Extend webhook registration to support filters
6
7
-[#1344](https://github.com/Shopify/shopify-api-ruby/pull/1344) Allow ShopifyAPI::Webhooks::Registry to update a webhook when fields or metafield_namespaces are changed.
7
8
-[#1343](https://github.com/Shopify/shopify-api-ruby/pull/1343) Make ShopifyAPI::Context::scope parameter optional. `scope` defaults to empty list `[]`.
If you need to filter the webhooks you want to receive, you can use a [webhooks filter](https://shopify.dev/docs/apps/build/webhooks/customize/filters), which can be specified on registration through the `filter` parameter.
**Note**: The webhooks you register with Shopify are saved in the Shopify platform, but the local `ShopifyAPI::Webhooks::Registry` needs to be reloaded whenever your server restarts.
0 commit comments