Java Code Examples for com.apollographql.apollo.api.Response#getData()
The following examples show how to use
com.apollographql.apollo.api.Response#getData() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RealApolloSubscriptionCall.java From apollo-android with MIT License | 6 votes |
@SuppressWarnings("unchecked") private Response<T> resolveFromCache() { final ResponseNormalizer<Record> responseNormalizer = apolloStore.cacheResponseNormalizer(); final ResponseFieldMapper responseFieldMapper = responseFieldMapperFactory.create(subscription); final ApolloStoreOperation<Response> apolloStoreOperation = apolloStore.read(subscription, responseFieldMapper, responseNormalizer, CacheHeaders.NONE); Response<T> cachedResponse = null; try { cachedResponse = apolloStoreOperation.execute(); } catch (Exception e) { logger.e(e, "Failed to fetch subscription `%s` from the store", subscription); } if (cachedResponse != null && cachedResponse.getData() != null) { logger.d("Cache HIT for subscription `%s`", subscription); return cachedResponse; } else { logger.d("Cache MISS for subscription `%s`", subscription); return null; } }
Example 2
Source File: ApolloCacheInterceptor.java From apollo-android with MIT License | 5 votes |
InterceptorResponse resolveFromCache(InterceptorRequest request) throws ApolloException { ResponseNormalizer<Record> responseNormalizer = apolloStore.cacheResponseNormalizer(); //noinspection unchecked ApolloStoreOperation<Response> apolloStoreOperation = apolloStore.read(request.operation, responseFieldMapper, responseNormalizer, request.cacheHeaders); Response cachedResponse = apolloStoreOperation.execute(); if (cachedResponse.getData() != null) { logger.d("Cache HIT for operation %s", request.operation); return new InterceptorResponse(null, cachedResponse, responseNormalizer.records()); } logger.d("Cache MISS for operation %s", request.operation); throw new ApolloException(String.format("Cache miss for operation %s", request.operation)); }