shopify_graphql 1.2.3 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 156829c756078d3acf1611b6a913337924259387e7c72968e601020286a49c92
4
- data.tar.gz: 1fd62af50279f6ebcb667007265773760a1daa110ad15557a0c95e0fa6ec9fcd
3
+ metadata.gz: f97b81964b9846562089ef6796741d90b2e83045fdc71976b4175d0166f7c896
4
+ data.tar.gz: fbedb085e356cb1419144c640a9efcf87e7045b552c1b71475a143797c381026
5
5
  SHA512:
6
- metadata.gz: b9741270fd1e3f46d946ab38fa05996717bbaac2057227499260ca737c439c3bbda2b1829d0da299b59f75aa9c2a5cf8df0e716dc564dd256cb88f9d71591003
7
- data.tar.gz: d83bb4edb850b5d9aedc11ff519684e242e49623a3f815a018524e45e2b1b0dfa8ebbef9241f66a78f3ae24917702d8e694c774e74f25b015cc7d0f2ef3590ab
6
+ metadata.gz: 33c833aeac55ec29ce6c345bc13d46cf58a8b022f719eefba187b72979ff4595066d8e9ee4dd1d64a5cc8e18f0a482bbe2cf9b920914f086435f8c5df30b3df1
7
+ data.tar.gz: ddc79cfe87487c19cafc81250413b3623b88808883c16c0fa557b39ea4c5c84d76841ded47ab8f76087af5d1664a3495a14485cf45cd199cb1b30f8029bcdcda
data/README.md CHANGED
@@ -685,6 +685,30 @@ ShopifyGraphql.handle_user_errors(response)
685
685
 
686
686
  Built-in wrappers are located in [`app/graphql/shopify_graphql`](/app/graphql/shopify_graphql/) folder. You can use them directly in your apps or as an example to create your own wrappers.
687
687
 
688
+ ## Rate limits
689
+
690
+ The gem exposes Graphql rate limit extensions in response object:
691
+
692
+ - `points_left`
693
+ - `points_limit`
694
+ - `points_restore_rate`
695
+ - `query_cost`
696
+
697
+ And adds a helper to check if available points lower than threshold (useful for implementing API backoff):
698
+
699
+ - `points_maxed?(threshold: 100)`
700
+
701
+ Usage example:
702
+
703
+ ```rb
704
+ response = GetProduct.call(id: "gid://shopify/Product/PRODUCT_GID")
705
+ response.points_left # => 1999
706
+ response.points_limit # => 2000.0
707
+ response.points_restore_rate # => 100.0
708
+ response.query_cost # => 1
709
+ response.points_maxed?(threshold: 100) # => false
710
+ ```
711
+
688
712
  ## Graphql webhooks
689
713
 
690
714
  > 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.
@@ -11,7 +11,7 @@ module ShopifyGraphql
11
11
  Response.new(handle_response(e.response))
12
12
  rescue JSON::ParserError => e
13
13
  raise ServerError.new(e, "Invalid JSON response")
14
- rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNREFUSED, Net::ReadTimeout, Net::OpenTimeout, OpenSSL::SSL::SSLError, EOFError => e
14
+ rescue Errno::ECONNRESET, Errno::EPIPE, Errno::ECONNREFUSED, Errno::ENETUNREACH, Net::ReadTimeout, Net::OpenTimeout, OpenSSL::SSL::SSLError, EOFError, Socket::ResolutionError => e
15
15
  raise ServerError.new(e, "Network error")
16
16
  end
17
17
 
@@ -1,3 +1,3 @@
1
1
  module ShopifyGraphql
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Platonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-26 00:00:00.000000000 Z
11
+ date: 2024-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails