Allow passing arbitrary `HTTParty` options in `ShopifyAPI::Clients::HttpClient`
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
Research direction
Start with lib/shopify_api/clients/http_client.rb, especially HttpClient#request and the initializer described in the issue. Confirm that arbitrary HTTParty options can be supplied while the existing headers, query, and body behavior remains intact, and verify the resulting request behavior with the project's HttpClient tests.
Written by the indexing model from the issue text.
Description
Overview
ShopifyAPI::Clients::HttpClient internally uses HTTParty to perform HTTP requests, but there is currently no way to pass through any HTTParty options (e.g. timeout, open_timeout, read_timeout, etc.). HttpClient#request hardcodes only headers, query, and body when calling HTTParty.send(...).
It would be helpful if HttpClient allowed passing an arbitrary set of HTTParty options, rather than only supporting specific ones, so that users can configure whichever options they need without waiting for the gem to add explicit support for each one.
Problem
Because none of HTTParty's other options are exposed, users of this gem have no way to bound request latency with timeout / open_timeout / read_timeout (e.g. for background jobs or requests with strict SLAs). Currently the only workaround is monkey-patching HttpClient, which is fragile across gem upgrades.
Proposed Solution
Rather than adding support for a single option like timeout, it may be more flexible to allow passing an arbitrary options hash that gets merged into the HTTParty call, e.g.:
sig { params(base_path: String, session: T.nilable(Auth::Session), httparty_options: T::Hash[Symbol, T.untyped]).void }
def initialize(base_path:, session: nil, httparty_options: {})
@httparty_options = httparty_options
# ...
end
# in #request
res = T.cast(HTTParty.send(
request.http_method,
parsed_uri.to_s,
**@httparty_options.merge(
headers: headers,
query: request.query,
body: ...,
),
), HTTParty::Response)
This would let users pass timeout:, open_timeout:, read_timeout:, or any other HTTParty-supported option, without the gem needing to explicitly enumerate and support each one individually.
Alternatives Considered
- Adding a dedicated
timeout:argument only — simpler, but doesn't generalize to other HTTParty options users may need. - Monkey-patching
HttpClient— works today but fragile across gem upgrades.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 484
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Shopify/shopify-api-ruby
-
devtools-gardener
Difficulty 3/5 1-2 days Newbie friendliness 67/100
Shopify/shopify-api-ruby#1461 · 1 comment ·
-
automated
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Shopify/shopify-api-ruby#1460 ·
-
devtools-gardener
Difficulty 5/5 Over a week Newbie friendliness 35/100
Shopify/shopify-api-ruby#1455 ·
-
devtools-gardener
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Shopify/shopify-api-ruby#1453 · 1 comment ·
-
automated
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Shopify/shopify-api-ruby#1452 ·
All issues in Shopify/shopify-api-ruby
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bensheldon/good_job#1816 · 5 comments ·