lucid-shopify 0.50.1 → 0.50.2

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: a3646156cad19df85980cce89c6f9383eefcc0eb8a95ea5b448fac6d442e61f6
4
- data.tar.gz: 35e124d5132365392399e561fe3c2cdc9d41bd2bc3ad116f0ce42ee8d9aac9af
3
+ metadata.gz: 7f831f0a86deaa7d4ba5b5150e287c4db5380de44e91278a2f37257a45e188c9
4
+ data.tar.gz: 027071d699cec5c4cb1948d7a39be74afc7125f360cca3ffd0588af73a51c2b3
5
5
  SHA512:
6
- metadata.gz: '068813c82d97d7303bac3cb690d4b164946a7462bbba7e82c65510d21c51201ebc2a84468a0def8517bf59ea47815c15bd07659fe528e38e72116dc9f5389738'
7
- data.tar.gz: d9989dc6f4b24942709adea0ec6fd35e3d55e11a570ee5626016b9ab80b1b65052ae5b7054c305cb0dd22df71db2884e9b73e4cbd7c1c72e7ec25a88636420e1
6
+ metadata.gz: 357be516c2a2a231db80409cac04e341ad7758fd2731e5fbd6e98a52fcdab9cbe6c42c827a714d1f5c9dfea66f45b2005f4eb918cbb3416673bc25ae49fb4cbe
7
+ data.tar.gz: ceb7df92ae20091390402ecae5c55ff55b427412a3ae6fc8df3de0a582c456d5c55222ce02d778739ca501fc5aaeb126bdc2ba451acc2ef195278a60364e1e51
@@ -131,7 +131,7 @@ module Lucid
131
131
 
132
132
  # @return [Boolean]
133
133
  def errors?
134
- return user_errors? if user_errors?
134
+ return true if user_errors?
135
135
 
136
136
  data_hash.has_key?('errors') # should be only on 422
137
137
  end
@@ -140,11 +140,29 @@ module Lucid
140
140
  #
141
141
  # @return [Boolean]
142
142
  private def user_errors?
143
- errors = data_hash.dig('data', 'userErrors')
143
+ errors = find_user_errors
144
144
 
145
145
  !errors.nil? && !errors.empty?
146
146
  end
147
147
 
148
+ # GraphQL user errors (find recursively).
149
+ #
150
+ # @param hash [Hash]
151
+ #
152
+ # @return [Array, nil]
153
+ private def find_user_errors(hash = data_hash)
154
+ return nil unless request.is_a?(PostGraphQLRequest)
155
+
156
+ hash.each do |k, v|
157
+ return v if k == 'userErrors'
158
+ if v.is_a?(Hash)
159
+ errors = find_user_errors(v)
160
+ return errors if errors
161
+ end
162
+ end
163
+ nil
164
+ end
165
+
148
166
  # A string rather than an object is returned by Shopify in the case of,
149
167
  # e.g., 'Not found'. In this case, we return it under the 'resource' key.
150
168
  #
@@ -167,11 +185,11 @@ module Lucid
167
185
  #
168
186
  # @return [Hash]
169
187
  private def user_errors
170
- errors = data_hash.dig('data', 'userErrors')
188
+ errors = find_user_errors
171
189
  return {} if errors.nil? || errors.empty?
172
190
  errors.map do |error|
173
191
  [
174
- error['field'],
192
+ error['field'].join('.'),
175
193
  error['message'],
176
194
  ]
177
195
  end.to_h
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lucid
4
4
  module Shopify
5
- VERSION = '0.50.1'
5
+ VERSION = '0.50.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.50.1
4
+ version: 0.50.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelsey Judson