Api not getting called queryGraph -> enqueue mobile-buy-sdk-android v: 3.5.0

Highlighted
New Member
3 0 0

Hello guys, I m building Android application for shopify. I was using mobile-sdk-android version 3.2.3. Everything was find until i stuck with apply discount on cart page.  Checkout api response does not return applied discount amount on cart. I searched a lot in sdk in checkout class. but not able to found it. Than i decide to go with latest version of android sdk.  

I converted my app from Java to Kotlin successfully. 

 

Now i m stuck with api from two days. Api is not getting called using mobile-sdk-android version 3.5.0. i tried with both languages Java and Kotlin. But no luck. I search here in forum. i found few post with checkout problem but those are not relate with my issues.  Any help is appreicated.  

 

graphClient = GraphClient.Companion.build(this, ShopifyBuildConfig.SHOP_DOMAIN, ShopifyBuildConfig.API_KEY,
        builder -> {
            //builder.setHttpClient(httpClient);
            /*builder.httpCache(getCacheDir(), config -> {
                //config.setCacheMaxSizeBytes(1024 * 1024 * 10);
                //config.setDefaultCachePolicy(HttpCachePolicy.Default.CACHE_FIRST.expireAfter(20, TimeUnit.MINUTES));
                return Unit.INSTANCE;
            });*/
            return Unit.INSTANCE;
        });

 

graphClient.queryGraph(query).enqueue(response -> {
                    if (response instanceof GraphCallResult.Failure) {
                        Log.e(TAG, "Call has been error -=> " + response);

                        GraphError error = ((GraphCallResult.Failure) response).getError();
                        if (error instanceof GraphError.CallCanceledError) {
                            Log.e(TAG, "Call has been canceled", error);
                        } else if (error instanceof GraphError.HttpError) {
                            Log.e(TAG, "Http request failed: " + ((GraphError.HttpError) error).getMessage(), error);
                        } else if (error instanceof GraphError.NetworkError) {
                            Log.e(TAG, "Network is not available", error);
                        } else if (error instanceof GraphError.ParseError) {
                            // in most cases should never happen
                            Log.e(TAG, "Failed to parse GraphQL response", error);
                        } else {
                            Log.e(TAG, "Failed to due to other error ", error);
                        }

                    } else {
                        Log.d(TAG, "Call has been success response => " + response);

                    }
                    return Unit.INSTANCE;
                }
        );

Let me know what changes need to done. I just need one working code after that i will manage myself to complete whole project within a week :P

 

Thanks 

0 Likes
New Member
3 0 0

Hey  @KarlOffenberger , i saw you were active and helping people with their problem. It will grateful to you if you can help me too.

Other people also welcome.

thanks 

 

 

  
0 Likes
New Member
3 0 0

I tried updating code according to sample app but still not able to get response nor error. Here is updated code. Please have a look. I tried passing Query = null graphclient query shows error. but passing complete query does not return anything. I double check API key and store address

 

//query for  product vendor name
Storefront.QueryRootQuery query = Storefront.query(shopQuery -> shopQuery.products(products -> products
.edges(edges -> edges.node(nodes -> nodes.vendor()))));

 

GraphCall<Storefront.QueryRoot> call = graphClient.queryGraph(query);
RxUtil.rxGraphQueryCall(call)
.map(it -> (Storefront.Product) it.getNode())
.subscribeOn(Schedulers.io());

 

public static Single<Storefront.QueryRoot> rxGraphQueryCall(final GraphCall<Storefront.QueryRoot> call) {
Log.d(TAG, "rxGraphQueryCall API Calling => ");

return Single.<GraphResponse<Storefront.QueryRoot>>create(emitter -> {
//emitter.setCancellable(call::cancel);
call.enqueue(result -> {
if (result instanceof GraphCallResult.Success) {
emitter.onSuccess(((GraphCallResult.Success<Storefront.QueryRoot>) result).getResponse());
} else {
emitter.onError(((GraphCallResult.Failure) result).getError());
}
return Unit.INSTANCE;
});
}).compose(queryResponseDataTransformer());
}
private static <T extends AbstractResponse<T>> SingleTransformer<GraphResponse<T>, T> queryResponseDataTransformer() {
Log.d(TAG, "queryResponseDataTransformer api");
return upstream -> upstream.flatMap(response -> {
Log.d(TAG, "SingleTransformer api response -> " + response);
if (response.getHasErrors()) {
String errorMessage = fold(new StringBuilder(), response.getErrors(),
(builder, error) -> builder.append(error.message()).append("\n")).toString();
return Single.error(new RuntimeException(errorMessage));
} else {
return Single.just(response.getData());
}
});
}

 

waiting for reply.

thanks

0 Likes