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 137 forks source link

Polling for shipping rates gives error "Failed to reschedule GraphQL query execution" #630

Open ranamrameez opened 4 years ago

ranamrameez commented 4 years ago

I am trying to get shipping rates using queryGraph but i am getting this error "Failed to reschedule GraphQL query execution". here is my code:

`GraphClient graphClient = ... graphClient.queryGraph(query).enqueue( new GraphCall.Callback() { @Override public void onResponse(@NonNull final GraphResponse response) { Storefront.Checkout checkout = (Storefront.Checkout) response.data().getNode(); List shippingRates = checkout.getAvailableShippingRates().getShippingRates(); Log.e("checkout", "shipping price:= " + shippingRates.get(0).getPrice()); }

                @Override
                public void onFailure(@NonNull final GraphError error) {
                    Log.e("checkout", "error= " + error.getMessage());
                }
            }
            ,
            null,
            RetryHandler.exponentialBackoff(500, TimeUnit.MILLISECONDS, 1.2f)
                    .whenResponse(
                            response -> {
                                Storefront.Checkout checkout = (Storefront.Checkout) response.data();
                                return checkout.getAvailableShippingRates().getReady() == false;
                            }
                    )
                    .maxCount(12)
                    .build()
    );`
Okiring commented 4 years ago

write your retryHandler as below:

RetryHandler.exponentialBackoff(800, TimeUnit.MILLISECONDS, 1.2f) .whenResponse( response -> ((Storefront.Checkout) ((GraphResponse)response).data().getNode()).getAvailableShippingRates().getReady() == false) .maxCount(20) .build()