Skip to content

Commit

Permalink
Deprecate ShopifyGrahpql webhooks (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillplatonov authored Oct 16, 2024
1 parent cc3ab68 commit b2596ad
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -793,9 +793,10 @@ Shop.with_shopify_session do
end
```
## Graphql webhooks
## Graphql webhooks (deprecated)
> Since version 10 `shopify_api` gem includes built-in support for Graphql webhooks. If you are using `shopify_api` version 10 or higher you don't need to use this gem to handle Graphql webhooks. See [`shopify_app` documentation](https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/webhooks.md) for more details.
> [!WARNING]
> ShopifyGraphql webhooks are deprecated and will be removed in v3.0. Please use `shopify_app` gem for handling webhooks. See [`shopify_app` documentation](https://github.com/Shopify/shopify_app/blob/main/docs/shopify_app/webhooks.md) for more details.
The gem has built-in support for Graphql webhooks (similar to `shopify_app`). To enable it add the following config to `config/initializers/shopify_app.rb`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ module WebhookVerification
include ShopifyGraphql::PayloadVerification

included do
before_action :deprecate_webhooks
skip_before_action :verify_authenticity_token, raise: false
before_action :verify_request
end

private

def deprecate_webhooks
ShopifyGraphql.deprecator.warn("ShopifyGraphql webhooks are deprecated and will be removed in v3.0. Please use shopify_app gem for handling webhooks.")
end

def verify_request
data = request.raw_post
return head(:unauthorized) unless hmac_valid?(data)
Expand Down
4 changes: 4 additions & 0 deletions lib/shopify_graphql/engine.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module ShopifyGraphql
def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("3.0", "ShopifyGraphql")
end

module RedactJobParams
private

Expand Down

0 comments on commit b2596ad

Please sign in to comment.