Shopify / shopify-api-ruby

ShopifyAPI is a lightweight gem for accessing the Shopify admin REST and GraphQL web services.
MIT License
1.06k stars 473 forks source link

Add T::Array[String] support for webhook fields #1189

Closed SheldonNunes closed 1 year ago

SheldonNunes commented 1 year ago

Description

This PR updates the sorbet signature for the Webhooks::Registry to support T::Array[String].

ShopifyApp.configure do |config|
  config.webhooks = [
    {topic: 'products/update', path: 'webhooks/products_update', fields: ['title', 'vendor']}
  ]
end

The examples currently described in ShopifyApp above do not work as the following error is encountered:

Parameter 'fields': Expected type T.nilable(String), got type Array with value ["title", "vendor"] (TypeError)

This PR updates the signature to match the underlying registration code which accepts both String and T::Array[String]

https://github.com/Shopify/shopify-api-ruby/blob/77ab36ca816516a677b736a46eec59aeed36a055/lib/shopify_api/webhooks/registration.rb#L24C19-L24C61

How has this been tested?

Added additional tests asserting the behaviour remains unchanged when passing in array.

Checklist: