shopify_graphql 1.2.4 → 1.2.6

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: 47a85b64907b2d5999db3a96db60838d6542c6f4e9fd0d90b49d26cb6226ffe7
4
- data.tar.gz: 2d2d7ee2590f32dfeceba741ec228158dbb13dca3737063bde1f23e69f9196fd
3
+ metadata.gz: a20f7b85f9a4a22fd1c3ea0509ec496f3447a2764fedf105539cab20274ed221
4
+ data.tar.gz: 966022527dd821e837c200d6c1df8ca84236b05ed5e311c6ac13dbabe00322f9
5
5
  SHA512:
6
- metadata.gz: aabf1fb4fb94328201f17873fdeba94667fc27f80fa3e265b3e103bf0decd01ca760c37f48b02698fcbc34242bd3a83b832d22bc644c319384a16fddf7ecaa91
7
- data.tar.gz: 5d3dbf44116974a3d5db0a140a1b6487f35fb12d0be85eda46e8580be9c7fe002c25acb3fbcea0f3e840c52840536fc1548c75897cd46fe3ad5c0443aabef995
6
+ metadata.gz: 02c0027937db4125f3a1146275a999e1c6657ebe28682d5e0da81d34fcebac78796877abc4e7d1572de84599a82033d2140cabd8afbdd9b39951e428a9d4644f
7
+ data.tar.gz: 4eeb9be4a243c5bcba638857a6bfa29f28e20a94ba1d3aa236ac30fdf7a2a6587bd4d74a6b7a53349118a60072458fc87fc255c16560b76b07c0d64c33e2ae13
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, Errno::ENETUNREACH, 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
 
@@ -47,6 +47,8 @@ module ShopifyGraphql
47
47
  raise PreconditionFailed.new(parsed_body(response), code: response.code)
48
48
  when 422
49
49
  raise ResourceInvalid.new(parsed_body(response), code: response.code)
50
+ when 423
51
+ raise ShopLocked.new(parsed_body(response), code: response.code)
50
52
  when 429, 430
51
53
  raise TooManyRequests.new(parsed_body(response), code: response.code)
52
54
  when 401...500
@@ -60,6 +60,10 @@ module ShopifyGraphql
60
60
  class PreconditionFailed < ClientError # :nodoc:
61
61
  end
62
62
 
63
+ # 423 Locked
64
+ class ShopLocked < ClientError # :nodoc:
65
+ end
66
+
63
67
  # 429 Too Many Requests
64
68
  class TooManyRequests < ClientError # :nodoc:
65
69
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyGraphql
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.6"
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.4
4
+ version: 1.2.6
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-04-18 00:00:00.000000000 Z
11
+ date: 2024-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails