shopify_graphql 2.1.0 → 2.2.0
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/app/graphql/shopify_graphql/create_bulk_mutation.rb +1 -0
- data/app/graphql/shopify_graphql/create_bulk_query.rb +1 -0
- data/app/graphql/shopify_graphql/get_bulk_operation.rb +5 -1
- data/lib/shopify_graphql/client.rb +36 -9
- data/lib/shopify_graphql/exceptions.rb +1 -1
- data/lib/shopify_graphql/version.rb +1 -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: 676b35a53c5124709bcb8760437d53e16678bfae111ddb757036df4c07d01fa0
|
4
|
+
data.tar.gz: a32e7e86b6bb543e27d234098225a399e6f38e49e330f7d871f51547943a9eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0f3ee5179384954a776d2afecc37a5377c123aecc99b352deb02fb71493792d911356c8a2a950ff9279cfaca0e39c2122d4f002e72ed43dee2e6e0e6e10de0b
|
7
|
+
data.tar.gz: ef42df04753e9acd8b3f7b37cddb4c35195dc443fd67300ff5fdbc69487602e3f7dcbda0f5b49f92af52272ac7e56a3db070b9dcff9914753639f3f4d9c07fc9
|
@@ -13,6 +13,8 @@ module ShopifyGraphql
|
|
13
13
|
completedAt
|
14
14
|
fileSize
|
15
15
|
url
|
16
|
+
objectCount
|
17
|
+
rootObjectCount
|
16
18
|
}
|
17
19
|
}
|
18
20
|
}
|
@@ -37,7 +39,9 @@ module ShopifyGraphql
|
|
37
39
|
error_code: data.errorCode,
|
38
40
|
created_at: Time.find_zone("UTC").parse(data.createdAt),
|
39
41
|
completed_at: data.completedAt ? Time.find_zone("UTC").parse(data.completedAt) : nil,
|
40
|
-
url: data.url
|
42
|
+
url: data.url,
|
43
|
+
object_count: data.objectCount.to_i,
|
44
|
+
root_object_count: data.rootObjectCount.to_i,
|
41
45
|
)
|
42
46
|
end
|
43
47
|
end
|
@@ -114,6 +114,8 @@ module ShopifyGraphql
|
|
114
114
|
ConnectionError.new(response: response)
|
115
115
|
end
|
116
116
|
exception.error_code = error_code
|
117
|
+
exception.error_codes = [ error_code ]
|
118
|
+
exception.messages = [ error.message ]
|
117
119
|
raise exception, error_message
|
118
120
|
end
|
119
121
|
|
@@ -121,27 +123,52 @@ module ShopifyGraphql
|
|
121
123
|
return response if response.userErrors.blank?
|
122
124
|
|
123
125
|
error = response.userErrors.first
|
124
|
-
|
125
|
-
error_message =
|
126
|
-
|
127
|
-
|
128
|
-
fields:
|
126
|
+
errors = response.userErrors
|
127
|
+
error_message = generate_user_errors_message(
|
128
|
+
messages: errors.map(&:message),
|
129
|
+
codes: errors.map(&:code),
|
130
|
+
fields: errors.map(&:field),
|
129
131
|
)
|
130
132
|
|
131
133
|
exception = UserError.new(response: response)
|
132
|
-
exception.error_code =
|
133
|
-
exception.
|
134
|
+
exception.error_code = error.code
|
135
|
+
exception.error_codes = errors.map(&:code)
|
136
|
+
exception.fields = errors.map(&:field)
|
137
|
+
exception.messages = errors.map(&:message)
|
134
138
|
raise exception, error_message
|
135
139
|
end
|
136
140
|
|
137
|
-
def generate_error_message(message: nil, code: nil, doc: nil
|
141
|
+
def generate_error_message(message: nil, code: nil, doc: nil)
|
138
142
|
string = "Failed.".dup
|
139
143
|
string << " Response code = #{code}." if code
|
140
144
|
string << " Response message = #{message}.".gsub("..", ".") if message
|
141
145
|
string << " Documentation = #{doc}." if doc
|
142
|
-
string << " Fields = #{fields}." if fields
|
143
146
|
string
|
144
147
|
end
|
148
|
+
|
149
|
+
def generate_user_errors_message(messages: nil, codes: nil, fields: [])
|
150
|
+
if fields.any?
|
151
|
+
field_count = fields.size
|
152
|
+
result = ["#{field_count} #{"field".pluralize(field_count)} have failed:"]
|
153
|
+
|
154
|
+
fields.each.with_index do |field, index|
|
155
|
+
field_details = ["\n-"]
|
156
|
+
field_details << "Response code = #{codes[index]}." if codes&.at(index)
|
157
|
+
field_details << "Response message = #{messages[index]}.".gsub("..", ".") if messages&.at(index)
|
158
|
+
field_details << "Field = #{field}." if field
|
159
|
+
|
160
|
+
result << field_details.join(" ")
|
161
|
+
end
|
162
|
+
|
163
|
+
result.join("\n")
|
164
|
+
else
|
165
|
+
result = ["Failed."]
|
166
|
+
result << "Response code = #{codes.join(", ")}." if codes&.any?
|
167
|
+
result << "Response message = #{messages&.join(", ")}.".gsub("..", ".") if messages&.any?
|
168
|
+
|
169
|
+
result.join(" ")
|
170
|
+
end
|
171
|
+
end
|
145
172
|
end
|
146
173
|
|
147
174
|
class << self
|
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: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kirill Platonov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|