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

getNode is not present in Pooling Shipping Rate RetryHander API : v3.2.3 #616

Closed ashu2121 closed 4 years ago

ashu2121 commented 4 years ago

Hello I m new in GraphQL.

I have implemented library version: 3.2.3 in my project. I m trying to get shipping rate from api to display, code start giving me compile time error. I m using pooling shipping rate api.

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

But `getNode` is not present i tried all the way to retrieve `getNode`. Here is full code

`graphClient.queryGraph(query).enqueue(
                new GraphCall.Callback<Storefront.QueryRoot>() {
                    @Override public void onResponse(@NonNull final GraphResponse<Storefront.QueryRoot> response) {
                        Storefront.Checkout checkout = (Storefront.Checkout) response.data().getNode();
                        List<Storefront.ShippingRate> shippingRates = checkout.getAvailableShippingRates().getShippingRates();
                        for(int i = 0; i<shippingRates.size();i++) {
                            Log.d(TAG, "shippingRates getPrice => " + shippingRates.get(i).getPrice());
                            Log.d(TAG, "shippingRates getTitle => " + shippingRates.get(i).getTitle());
                        }
                    }

                    @Override public void onFailure(@NonNull final GraphError error) {
                    }
                },
                null,
                RetryHandler.exponentialBackoff(800, TimeUnit.MILLISECONDS, 1.2f)
                        .whenResponse(
                                response -> ((Storefront.Checkout)response.data().getNode()).getAvailableShippingRates().getReady() == false
                        )
                        .maxCount(12)
                        .build()
         );

can anyone guide me on how to use a retry handler in pooling shipping rate api. Althuogh i can make another retry handler using this library. but it will cost resources and battery. Better i want to use a built-in retry handler.

thanks in advance

ashu2121 commented 4 years ago

i tried changing the code like below to get getNode()

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

But i m getting error Failed to execute GraphQL request, getNode on null reference. Do anyone guide me what i m doing wrong?

thanks in advance.

ashu2121 commented 4 years ago

actually getNode present in version 3.2.3. that's why i had to update the version to newer. Now everything works great. thanks