shopify_api-graphql-tiny 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -3
- data/Changes +5 -0
- data/README.md +36 -0
- data/lib/shopify_api/graphql/tiny/version.rb +1 -1
- data/lib/shopify_api/graphql/tiny.rb +13 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d550d3eaf0d6ac8c9701e0e5d140dffe49fdf43cdb0d709b9e0d94042b7527c
|
|
4
|
+
data.tar.gz: a588f78468f1bcc1208229d0173648cfeb6f29fb93a64869e1b6e84722bfc920
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fe4aa237dc1d694b541b33b400fdf5890001364a22e9cc81f84ab2ca27a74b795795072ed887dd40b5391d1a089901dec5b445ffaa1071e7865eb02dd99508dd
|
|
7
|
+
data.tar.gz: 8b8249432936e22fa01679d0755ad97b7f63383b440c9b5c8b9c0f8f198222e937c7a5b139e9fb42ecef5d595ef1ed80d28e92b980dd10e632f18c563239e8e8
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -9,16 +9,17 @@ jobs:
|
|
|
9
9
|
runs-on: ubuntu-latest
|
|
10
10
|
env:
|
|
11
11
|
SHOPIFY_DOMAIN: "${{ secrets.SHOPIFY_DOMAIN }}"
|
|
12
|
-
|
|
12
|
+
SHOPIFY_ADMIN_TOKEN: "${{ secrets.SHOPIFY_ADMIN_TOKEN }}"
|
|
13
|
+
SHOPIFY_STOREFRONT_TOKEN: "${{ secrets.SHOPIFY_STOREFRONT_TOKEN }}"
|
|
13
14
|
SHOPIFY_CUSTOMER_ID: "${{ secrets.SHOPIFY_CUSTOMER_ID }}"
|
|
14
15
|
SHOPIFY_PRODUCT_ID: "${{ secrets.SHOPIFY_PRODUCT_ID }}"
|
|
15
16
|
|
|
16
17
|
strategy:
|
|
17
18
|
matrix:
|
|
18
|
-
ruby: ['3.4', '3.3', '3.2', '3.1', '3.0', '2.7']
|
|
19
|
+
ruby: ['4.0', '3.4', '3.3', '3.2', '3.1', '3.0', '2.7']
|
|
19
20
|
|
|
20
21
|
steps:
|
|
21
|
-
- uses: actions/checkout@
|
|
22
|
+
- uses: actions/checkout@v7
|
|
22
23
|
- uses: ruby/setup-ruby@v1
|
|
23
24
|
with:
|
|
24
25
|
bundler-cache: true
|
data/Changes
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
2026-11-17 v1.1.1
|
|
2
|
+
--------------------
|
|
3
|
+
* Add support for Pager#cursor to expose the current page's cursor
|
|
4
|
+
* Don't mutate a pagination caller's variable argument
|
|
5
|
+
|
|
1
6
|
2026-06-25 v1.1.0
|
|
2
7
|
--------------------
|
|
3
8
|
* Add support for requests against the storefront API
|
data/README.md
CHANGED
|
@@ -92,6 +92,12 @@ result = gql.execute(<<-GQL, :id => your_gid)
|
|
|
92
92
|
GQL
|
|
93
93
|
```
|
|
94
94
|
|
|
95
|
+
You can set the storefront buyer's IP address (`Shopify-Storefront-Buyer-IP` HTTP header) via the `:ip` option:
|
|
96
|
+
|
|
97
|
+
```rb
|
|
98
|
+
gql = ShopifyAPI::GraphQL::Tiny.new("my-shop", token, :storefront => true, :ip => request.remote_ip)
|
|
99
|
+
```
|
|
100
|
+
|
|
95
101
|
### Automatically Retrying Failed Requests
|
|
96
102
|
|
|
97
103
|
There are 2 types of retries: 1) request is rate-limited by Shopify 2) request fails due to an exception or non-200 HTTP response.
|
|
@@ -147,6 +153,24 @@ These can be overridden globally (by assigning to the constant) or per instance:
|
|
|
147
153
|
gql = ShopifyAPI::GraphQL::Tiny.new(shop, token, :retry => [SystemCallError, "500"])
|
|
148
154
|
```
|
|
149
155
|
|
|
156
|
+
Also see [Token Expiry](#token-expiry).
|
|
157
|
+
|
|
158
|
+
### Token Expiry
|
|
159
|
+
|
|
160
|
+
`ShopifyAPI::GraphQL::Tiny` does not handle refreshing expired or expiring tokens. Remember, it's tiny!
|
|
161
|
+
To handle token refresh and migration use [`ShopifyAPI::GraphQL::Request`](https://github.com/ScreenStaring/shopify_api-graphql-request)
|
|
162
|
+
which is a higher-level wrapper around this class.
|
|
163
|
+
|
|
164
|
+
### Timeouts
|
|
165
|
+
|
|
166
|
+
Use the `:open_timeout` and `:read_timeout` options. They apply to the initial request and any retries:
|
|
167
|
+
|
|
168
|
+
```rb
|
|
169
|
+
gql = ShopifyAPI::GraphQL::Tiny.new("my-shop", token, :open_timeout => 5, :read_timeout => 15)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Both default to `Net::HTTP`'s defaults.
|
|
173
|
+
|
|
150
174
|
#### Disabling Automatic Retry
|
|
151
175
|
|
|
152
176
|
To disable retries set the `:retry` option to `false`:
|
|
@@ -185,6 +209,18 @@ results = pager.execute(query, :foo => 123)
|
|
|
185
209
|
results.each { |page| ... }
|
|
186
210
|
```
|
|
187
211
|
|
|
212
|
+
`pager` contains a `#cursor` method that returns the GraphQL pagination cursor's current value. It is updated after each iteration:
|
|
213
|
+
```rb
|
|
214
|
+
results = pager.execute(query, :foo => 123)
|
|
215
|
+
results.each do |page|
|
|
216
|
+
puts "Cursor: #{pager.cursor}"
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
pager.execute(query, :foo => 123).each do |page|
|
|
220
|
+
puts "Cursor: #{pager.cursor}"
|
|
221
|
+
end
|
|
222
|
+
```
|
|
223
|
+
|
|
188
224
|
#### `after` Pagination
|
|
189
225
|
|
|
190
226
|
To use `after` pagination, i.e., to paginate forward, your query must:
|
|
@@ -84,6 +84,8 @@ module ShopifyAPI
|
|
|
84
84
|
# [:version (String)] Shopify API version to use. Defaults to the latest version.
|
|
85
85
|
# [:storefront (Boolean)] If +true+ use the Storefront API instead of Admin API. Defaults to +false+.
|
|
86
86
|
# [:ip (String)] Optional buyer IP address for Storefront API (sets X-Shopify-Storefront-Buyer-IP header). Only used when :storefront is +true+.
|
|
87
|
+
# [:open_timeout (Numeric)] Number of seconds to wait for the connection to open. Defaults to Net::HTTP's default.
|
|
88
|
+
# [:read_timeout (Numeric)] Number of seconds to wait for a response. Defaults to Net::HTTP's default.
|
|
87
89
|
# [:max_attempts (Integer)] Maximum number of retry attempts across all errors. Defaults to +10+
|
|
88
90
|
# [:base_delay (Float)] Exponential backoff base delay. Defaults to +0.5+
|
|
89
91
|
# [:jitter (Boolean)] Exponential backoff jitter (random delay added to backoff). Defaults to +true+
|
|
@@ -105,6 +107,8 @@ module ShopifyAPI
|
|
|
105
107
|
|
|
106
108
|
@raise_on_warnings = @options[:raise_on_warnings]
|
|
107
109
|
@storefront = !!@options[:storefront]
|
|
110
|
+
@open_timeout = @options[:open_timeout]
|
|
111
|
+
@read_timeout = @options[:read_timeout]
|
|
108
112
|
|
|
109
113
|
@headers = DEFAULT_HEADERS.dup
|
|
110
114
|
|
|
@@ -270,6 +274,8 @@ module ShopifyAPI
|
|
|
270
274
|
|
|
271
275
|
request = Net::HTTP.new(@endpoint.host, @endpoint.port)
|
|
272
276
|
request.use_ssl = true
|
|
277
|
+
request.open_timeout = @open_timeout if @open_timeout
|
|
278
|
+
request.read_timeout = @read_timeout if @read_timeout
|
|
273
279
|
request.set_debug_output(@debug) if @debug
|
|
274
280
|
|
|
275
281
|
request.start { |http| http.request(post) }
|
|
@@ -395,6 +401,8 @@ module ShopifyAPI
|
|
|
395
401
|
:after => %w[hasNextPage endCursor].freeze
|
|
396
402
|
}.freeze
|
|
397
403
|
|
|
404
|
+
attr_reader :cursor
|
|
405
|
+
|
|
398
406
|
def initialize(gql, *options)
|
|
399
407
|
@gql = gql
|
|
400
408
|
@options = normalize_options(options)
|
|
@@ -405,7 +413,8 @@ module ShopifyAPI
|
|
|
405
413
|
raise ArgumentError, "query does not contain the pagination variable '#{@options[:variable]}'"
|
|
406
414
|
end
|
|
407
415
|
|
|
408
|
-
variables
|
|
416
|
+
variables = (variables || {}).dup
|
|
417
|
+
@cursor = variables[@options[:variable]] || variables[@options[:variable].to_sym]
|
|
409
418
|
pagination_finder = @options[@options[:direction]]
|
|
410
419
|
|
|
411
420
|
enumerator = Enumerator.new do |y|
|
|
@@ -413,10 +422,10 @@ module ShopifyAPI
|
|
|
413
422
|
page = @gql.execute(q, variables)
|
|
414
423
|
y << page
|
|
415
424
|
|
|
416
|
-
cursor = pagination_finder[page]
|
|
417
|
-
break unless cursor
|
|
425
|
+
@cursor = pagination_finder[page]
|
|
426
|
+
break unless @cursor
|
|
418
427
|
|
|
419
|
-
variables[@options[:variable]] = cursor
|
|
428
|
+
variables[@options[:variable]] = @cursor
|
|
420
429
|
end
|
|
421
430
|
end
|
|
422
431
|
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shopify_api-graphql-tiny
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Skye Shaw
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-11-18 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: net_http_timeout_errors
|