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

Can't add custom headers in Rest Resource queries since v10 upgrade. #1211

Closed zzooeeyy closed 9 months ago

zzooeeyy commented 1 year ago

Issue summary

Before shopify-api-ruby v10 upgrade, you can set the Rest API request headers directly in the initializer: ShopifyAPI::Base.header['Header'] = 'value'

After the v10 upgrade, it looks like we don’t have a way to set headers on any Rest Resource calls anymore, you can only use extra headers if you use the actual Rest Client ..

########### Using Rest Client class:
client = ShopifyAPI::Clients::Rest::Admin.new(session: session)
response = client.get(path: "products", headers: {"MyHeader": "value"})
########### Using Rest Resource:
ShopifyAPI::Rest::Product.all 
# There is no option to pass in any extra header information because ShopifyAPI::Rest::Base.request doesn't accept it

ShopifyAPI::Rest::Base.request <- Doesn’t accept extra headers when making any requests ShopifyAPI::Clients::Rest::Admin.make_request <- Accepts extra headers when making requests

Expected behavior

There should be at least feature parity for the Rest client vs Rest resources. We should add extra header support for Rest resources.