@Override public void willResolveRootQuery(Operation operation) { willResolveRecord(CacheKeyResolver.rootKeyForOperation(operation)); }
@Nullable @Override public T execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), CacheHeaders.NONE); if (rootRecord == null) { return null; } ResponseFieldMapper<D> responseFieldMapper = operation.responseFieldMapper(); CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), CacheHeaders.NONE, cacheKeyBuilder); //noinspection unchecked RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, ResponseNormalizer.NO_OP_NORMALIZER); return operation.wrapData(responseFieldMapper.map(responseReader)); } });
@NotNull @Override public Response<T> execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), cacheHeaders); if (rootRecord == null) { return Response.<T>builder(operation).fromCache(true).build(); } CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), cacheHeaders, cacheKeyBuilder); RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, responseNormalizer); try { responseNormalizer.willResolveRootQuery(operation); T data = operation.wrapData(responseFieldMapper.map(responseReader)); return Response.<T>builder(operation) .data(data) .fromCache(true) .dependentKeys(responseNormalizer.dependentKeys()) .build(); } catch (Exception e) { logger.e(e, "Failed to read cache response"); return Response.<T>builder(operation).fromCache(true).build(); } } });
@Override public void willResolveRootQuery(Operation operation) { willResolveRecord(CacheKeyResolver.rootKeyForOperation(operation)); }
@Override public void willResolveRootQuery(Operation operation) { willResolveRecord(CacheKeyResolver.rootKeyForOperation(operation)); }
@Nullable @Override public T execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), CacheHeaders.NONE); if (rootRecord == null) { return null; } ResponseFieldMapper<D> responseFieldMapper = operation.responseFieldMapper(); CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), CacheHeaders.NONE); //noinspection unchecked RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, ResponseNormalizer.NO_OP_NORMALIZER); return operation.wrapData(responseFieldMapper.map(responseReader)); } });
@Nullable @Override public T execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), CacheHeaders.NONE); if (rootRecord == null) { return null; } ResponseFieldMapper<D> responseFieldMapper = operation.responseFieldMapper(); CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), CacheHeaders.NONE); //noinspection unchecked RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, ResponseNormalizer.NO_OP_NORMALIZER); return operation.wrapData(responseFieldMapper.map(responseReader)); } });
@Nonnull @Override public Response<T> execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), cacheHeaders); if (rootRecord == null) { return Response.<T>builder(operation).fromCache(true).build(); } CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), cacheHeaders); RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, responseNormalizer); try { responseNormalizer.willResolveRootQuery(operation); T data = operation.wrapData(responseFieldMapper.map(responseReader)); return Response.<T>builder(operation) .data(data) .fromCache(true) .dependentKeys(responseNormalizer.dependentKeys()) .build(); } catch (Exception e) { logger.e(e, "Failed to read cache response"); return Response.<T>builder(operation).fromCache(true).build(); } } });
@Nonnull @Override public Response<T> execute(ReadableStore cache) { Record rootRecord = cache.read(CacheKeyResolver.rootKeyForOperation(operation).key(), cacheHeaders); if (rootRecord == null) { return Response.<T>builder(operation).fromCache(true).build(); } CacheFieldValueResolver fieldValueResolver = new CacheFieldValueResolver(cache, operation.variables(), cacheKeyResolver(), cacheHeaders); RealResponseReader<Record> responseReader = new RealResponseReader<>(operation.variables(), rootRecord, fieldValueResolver, scalarTypeAdapters, responseNormalizer); try { responseNormalizer.willResolveRootQuery(operation); T data = operation.wrapData(responseFieldMapper.map(responseReader)); return Response.<T>builder(operation) .data(data) .fromCache(true) .dependentKeys(responseNormalizer.dependentKeys()) .build(); } catch (Exception e) { logger.e(e, "Failed to read cache response"); return Response.<T>builder(operation).fromCache(true).build(); } } });