Skip to content

Support local-only fields #2391

@tgyhlsb

Description

@tgyhlsb

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, flatMap or combineLatest out 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/

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenIssues related to or arising from code generationfeatureNew addition or enhancement to existing solutionsv1.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions