Partial cache reads
The cache supports partial cache reads, in a similar way to how GraphQL supports partial responses. This means that if some fields are missing from the cache, the cache returns the available data along with any errors for the missing fields.
With ApolloStore
The ApolloStore.readOperation() API returns an ApolloResponse<D> that can contain partial data and non-empty errors for any missing (or stale) fields in the cache.
If a cache miss exception is preferred, you can use the ApolloResponse<D>.errorsAsException() extension function that returns a response with an exception if there are any errors.
With ApolloClient
When executing operations, the built-in fetch policies (FetchPolicy.CacheFirst, FetchPolicy.CacheOnly, etc.) will treat cache misses as exceptions (partial results are disabled) by default.
To benefit from partial cache reads, you can set throwOnCacheMiss(false), or implement your own fetch policy interceptor as shown in this example:
Error stored in the cache
Errors from the server are stored in the cache, and will be returned when reading it.
By default, errors don't replace existing data in the cache. You can change this behavior with errorsReplaceCachedValues(true).