-
Notifications
You must be signed in to change notification settings - Fork 749
Description
Feature request
Local-only fields as the web framework supports: https://www.apollographql.com/docs/react/local-state/managing-state-with-field-policies/
Motivation
We have been trying to use Apollo cache as the source of truth of our data model since we moved to GQL. But we have more and more properties that only belong to the client (mostly the upload state of objects or properties related to optimistic behaviors of mutations).
To do this, we mix the cache with other in-memory storages, and build data streams to merge those before exposing the data to upper layers of the app.
The biggest pain points we face:
- We have many isolated in-memory storages that will require their own persistence mechanism once we want offline support.
- The complexity of the app increases quickly due to all those complex stream to merge data.
- We heavily dependent on Combine to build those streams. But we are now building an SDK and we want a lower minimum iOS version (and as few dependencies as possible), forcing use to work with closures instead. Making the streams even more complex (no
map,flatMaporcombineLatestout of the box). - Mixing local-only fragments (not yet sent to the server), properties stored outside of the cache and paginated lists makes it exponentially complex to maintain.
If this feature is not planed in the roadmap we plan to move our source of truth to some DB (CoreData or Realm) and use Apollo for the transport layer only. But that would mean using only a small subset of what your framework offers.
Proposed solution
Implement https://www.apollographql.com/docs/react/local-state/managing-state-with-field-policies/