-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CustomerAddress.all returning empty array #1192
Conversation
|
||
response = response.first if response.respond_to?(:first) | ||
|
||
# Assert attributes are correctly typed preventing Sorbet errors downstream | ||
if response.respond_to?(:original_state) | ||
response&.original_state&.each do |key, value| | ||
next if key == :default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this, but I'm not sure how to better handle. default
is both an attribute and a method.
5e20ba1
to
d85f0dd
Compare
Upon further review, this isn't going to work. The keys are different between Customer and CustomerAddress. When fetching a Customer, the key is |
Previously, when fetching `all` on CustomerAddress it would return an empty array. Two issues (Shopify#970, Shopify#1018) were opened outlining the problem. Initial attempt was to override `json_response_body_name` which worked for fetching arrays of results. It doesn't work for fetching individual results though. I wound up overriding `create_instances_from_response` for CustomerAddress. It isn't ideal but it does seem to behave correctly. Assertions have been added to the the tests as well.
d85f0dd
to
70bdc58
Compare
Looking for comments here. If this makes sense, I'll update the other API versions as well. |
Thanks for your contributions here! Unfortunately, we won't be able to use them as written as these resources are generated from a schema. Having said that, we can take this fix and apply it at the root layer so we don't regenerate these resources and lose your work. We have plans to open source that REST resource generation logic to enable the community to be more proactive with these fixes, but for now we'll ask for a little more time as we make this fix. We have resources dedicated to closing out open issues, so it shouldn't be too much longer! |
Description
Fixes #1018, #970
When fetching CustomerAddresses, the results are returned as
addresses
. This PR addsjson_response_body_name
to the class and updates tests.How has this been tested?
Assertions added to count the returned results.
Checklist: