Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate ShopifyGrahpql webhooks #52

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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