shopify_api-graphql-request 0.1.0 → 0.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/Changes +4 -0
- data/README.md +4 -2
- data/lib/shopify_api/graphql/request/oauth/access_token_migrator.rb +9 -3
- data/lib/shopify_api/graphql/request/version.rb +1 -1
- data/lib/tasks/shopify.rake +11 -1
- 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: 8693e4abd154bf4592d8582f4f00c542a22440a47554529cabca27a2acca9102
|
|
4
|
+
data.tar.gz: 2baa318c0578781d9419bb7916d26eeb59a09783d4ccaddfe577d485a9a6a3da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2ea1da8888f62de6903138ae9f116578f155e044a6375ee2646f8ae416c2b4ba53c903e7adc9922fa85d02d8d5f6cb48a9244251d78d9650d3f6a85019127177
|
|
7
|
+
data.tar.gz: dec264b7bcdf723b6e0da2ed3c5d7554f645797e5f4ace298effb046b2aca1da7077b977e2b06d46c82ce840af158c605e470787ee6d1b10a98b916929fc7b05
|
data/Changes
CHANGED
data/README.md
CHANGED
|
@@ -290,8 +290,8 @@ bundle exec rake shopify_api:graphql:request:migrate_access_tokens SHOPIFY_API_K
|
|
|
290
290
|
bundle exec rake shopify_api:graphql:request:migrate_access_tokens SHOPIFY_API_KEY=X SHOPIFY_API_SECRET=Y FILE=tokens.csv HANDLER=update_token.rb
|
|
291
291
|
```
|
|
292
292
|
|
|
293
|
-
A single shop's tokens are always printed. `HANDLER=file.rb` is required with `FILE` (nothing is printed for CSV) and optional with `SHOP`. Use it to persist the new tokens.
|
|
294
|
-
shop and the return value of `#migrate`:
|
|
293
|
+
A single shop's tokens are always printed. `HANDLER=file.rb` is required with `FILE` (nothing is printed for CSV) and optional with `SHOP`. Use it to persist the new tokens.
|
|
294
|
+
The file is `load`ed and must define `update_token(shop, tokens)`, which is called with the shop and the return value of `#migrate`:
|
|
295
295
|
|
|
296
296
|
```rb
|
|
297
297
|
# update_token.rb
|
|
@@ -304,6 +304,8 @@ end
|
|
|
304
304
|
bundle exec rake shopify_api:graphql:request:migrate_access_tokens SHOPIFY_API_KEY=X SHOPIFY_API_SECRET=Y FILE=tokens.csv HANDLER=update_token.rb
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
+
A summary of succeeded and failed shops (with the error for each failure) is printed when done. A failure for one shop does not stop the others; the task exits with status 1 if any shop failed.
|
|
308
|
+
|
|
307
309
|
#### Recovering a Lost Response
|
|
308
310
|
|
|
309
311
|
If a migration request fails or the response is lost, you can safely repeat the `#migrate` call with the original non-expiring token within
|
|
@@ -58,11 +58,15 @@ module ShopifyAPI
|
|
|
58
58
|
#
|
|
59
59
|
# === Returns
|
|
60
60
|
#
|
|
61
|
-
# [Array<Hash>] One
|
|
61
|
+
# [Array<Hash>] One status per shop, in input order:
|
|
62
|
+
# +{ :shop => String, :result => Hash, :error => nil }+ or
|
|
63
|
+
# +{ :shop => String, :result => nil, :error => String }+.
|
|
64
|
+
# Per-shop errors (+StandardError+, including those raised by the handler) are
|
|
65
|
+
# rescued so one failure does not stop the rest.
|
|
62
66
|
#
|
|
63
67
|
# === Errors
|
|
64
68
|
#
|
|
65
|
-
# ArgumentError
|
|
69
|
+
# ArgumentError for invalid input (before any shop is processed)
|
|
66
70
|
#
|
|
67
71
|
def run
|
|
68
72
|
pairs = @shop ? [single_shop_and_token] : rows
|
|
@@ -111,7 +115,9 @@ module ShopifyAPI
|
|
|
111
115
|
|
|
112
116
|
call_handler(result, shop) if @handler
|
|
113
117
|
|
|
114
|
-
{ :shop => shop, :result => result }
|
|
118
|
+
{ :shop => shop, :result => result, :error => nil }
|
|
119
|
+
rescue StandardError => e
|
|
120
|
+
{ :shop => shop, :result => nil, :error => "#{e.class}: #{e.message}" }
|
|
115
121
|
end
|
|
116
122
|
|
|
117
123
|
def call_handler(result, shop)
|
data/lib/tasks/shopify.rake
CHANGED
|
@@ -15,7 +15,7 @@ namespace :shopify_api do
|
|
|
15
15
|
abort "SHOPIFY_API_SECRET required" if client_secret.empty?
|
|
16
16
|
|
|
17
17
|
begin
|
|
18
|
-
ShopifyAPI::GraphQL::Request::OAuth::AccessTokenMigrator.new(
|
|
18
|
+
statuses = ShopifyAPI::GraphQL::Request::OAuth::AccessTokenMigrator.new(
|
|
19
19
|
client_id,
|
|
20
20
|
client_secret,
|
|
21
21
|
:shop => ENV["SHOP"],
|
|
@@ -26,6 +26,16 @@ namespace :shopify_api do
|
|
|
26
26
|
rescue ArgumentError => e
|
|
27
27
|
abort e.message
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
failed, succeeded = statuses.partition { |status| status[:error] }
|
|
31
|
+
|
|
32
|
+
puts "Succeeded (#{succeeded.size}):"
|
|
33
|
+
succeeded.each { |status| puts " #{status[:shop]}" }
|
|
34
|
+
|
|
35
|
+
puts "Failed (#{failed.size}):"
|
|
36
|
+
failed.each { |status| puts " #{status[:shop]}: #{status[:error]}" }
|
|
37
|
+
|
|
38
|
+
exit 1 unless failed.empty?
|
|
29
39
|
end
|
|
30
40
|
end
|
|
31
41
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shopify_api-graphql-request
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Skye Shaw
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: shopify_api-graphql-tiny
|