I am using apollo client https://github.com/apollographql/apollo-android to query Graphql API. In Graphql Server, we are returning with HTTPS status
return Response.status( Status.BAD_REQUEST ).entity( exception.getMessage() ).build();
How can I get HTTPS status code in response at client side?
Client code
ApolloCall<T> apolloCall = apolloClient.query( query );
Response<T> response = Rx2Apollo.from( apolloCall ).onErrorReturn( throwable -> null ).blockingFirst();
I majorly want to know whether the error is client exception or server exceeption.
You can remove the
.onErrorReturn( throwable -> null )
part and the HTTP error will be returned inonError
as aApolloHttpException
on which you can call.code()
to get the HTTP code.