Skip to content

Commit d80578e

Browse files
committed
Add a migration guide for v.15.0.0
1 parent 95817a1 commit d80578e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

BREAKING_CHANGES_FOR_V15.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Breaking change notice for version 15.0.0
2+
3+
## Removal of `ShopifyAPI::Webhooks::Handler`
4+
5+
The `ShopifyAPI::Webhooks::Handler` class has been removed in favor of `ShopifyAPI::Webhooks::WebhookHandler`. The `ShopifyAPI::Webhooks::WebhookHandler` class is now the recommended way to handle webhooks.
6+
7+
Make a module or class that includes or extends `ShopifyAPI::Webhooks::WebhookHandler` and implement the `handle` method which accepts the following named parameters: data: `WebhookMetadata`.
8+
9+
In v14, adding new fields to the callback would become a breaking change. To make this code more flexible, handlers will now receive an object that can be typed and extended.
10+
11+
`data` will have the following keys
12+
- `topic`, `String` - The topic of the webhook
13+
- `shop`, `String` - The shop domain of the webhook
14+
- `body`, `T::Hash[String, T.untyped]`- The body of the webhook
15+
- `webhook_id`, `String` - The id of the webhook event to [avoid duplicates](https://shopify.dev/docs/apps/webhooks/best-practices#ignore-duplicates)
16+
- `api_version`, `String` - The api version of the webhook
17+
18+
### New implementation
19+
```ruby
20+
module WebhookHandler
21+
extend ShopifyAPI::Webhooks::WebhookHandler
22+
23+
class << self
24+
def handle_webhook(data:)
25+
puts "Received webhook! topic: #{data.topic} shop: #{data.shop} body: #{data.body} webhook_id: #{data.webhook_id} api_version: #{data.api_version"
26+
end
27+
end
28+
end
29+
```
30+
31+
### Previous implementation
32+
```ruby
33+
module WebhookHandler
34+
include ShopifyAPI::Webhooks::Handler
35+
36+
class << self
37+
def handle(topic:, shop:, body:)
38+
puts "Received webhook! topic: #{topic} shop: #{shop} body: #{body}"
39+
end
40+
end
41+
end
42+
```

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Once your app can perform OAuth, it can now make authenticated Shopify API calls
7979

8080
## Breaking Change Notices
8181

82+
### Breaking change notice for version 15.0.0
83+
See [BREAKING_CHANGES_FOR_V15](BREAKING_CHANGES_FOR_V15.md)
84+
8285
### Breaking change notice for version 10.0.0
8386
See [BREAKING_CHANGES_FOR_V10](BREAKING_CHANGES_FOR_V10.md)
8487

0 commit comments

Comments
 (0)