【发布时间】:2021-05-07 13:58:42
【问题描述】:
我正在使用 apollo 客户端 https://github.com/apollographql/apollo-android 来查询 Graphql API。在 Graphql Server 中,我们返回的是 HTTPS 状态
return Response.status( Status.BAD_REQUEST ).entity( exception.getMessage() ).build();
如何在客户端获取 HTTPS 状态码作为响应?
客户端代码
ApolloCall<T> apolloCall = apolloClient.query( query );
Response<T> response = Rx2Apollo.from( apolloCall ).onErrorReturn( throwable -> null ).blockingFirst();
我主要想知道错误是客户端异常还是服务器异常。
【问题讨论】:
-
响应包含
data和errors(如果存在错误)道具 -
github.com/apollographql/apollo-android/blob/… @xadm 错误不包含 HTTPS 状态。
-
@xadm 它仍然为您提供消息:${message},位置:${locations},路径:${path},但没有 http 状态。状态有助于了解它是服务器错误还是客户端错误。
标签: android graphql apollo-client apollo-android