Shopify / mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.
MIT License
214 stars 136 forks source link

AbstractResponse hasErrors() should return true if any errors foudn #586

Open dri94 opened 5 years ago

dri94 commented 5 years ago

The hasErrors() method on AbstractResponse does not follow infer what a developer would think. This method makes it seem that it will return true if there are any errors in the query, however it only returns true if there are errors with retrieving the very top level of the query. hasErrors() should return true if any errors are found.

For example:

        val mutationQuery = Storefront.mutation { mutation ->
            mutation.customerCreate(input) { query ->
                query.customer { customer ->
                    customer
                            .id()
                            .email()
                            .firstName()
                            .lastName()
                }.userErrors { userError ->
                    userError
                            .field()
                            .message()
                }
            }
        }

If a userError is found in the above method, hasErrors() will still return false, even though an error was in fact found. If GraphQL is going to be used then we must at least escalate up some info to avoid these kind of issues