Codegen config for enabling full mutability of response models #3246
Labels
codegen
Issues related to or arising from code generation
feature
New addition or enhancement to existing solutions
medium-priority
Milestone
Use case
Hi,
We are trying to migrate from Apollo 0.53 to 1.5
So far, the main struggle we have is with the cache mutability.
We heavily relay on all types being mutable (which is no longer the case since v1) for
While small cache mutations for a single type can easily be migrated to using mutable fragments of the given type, this does not work for entire Queries containing a connection where we need to mutate (add/remove) the nodes. We have an abstraction that can handle connection pagination in a generic way with a single query watcher, but it relays on the ability to mutate the types.
TL;DR;
The problem - we wan't to be able to use same types for performing queries and mutating their data into the cache.
The request - add the ability, via codegen config or some custom directive or some other way, to enable full mutability to any type within any query.
Here is an example (simplified, non-generic):
What we have tried so far
mutate properties of the fragment instead.
ItemsPage
fragment, because it has noid
-> there is noCacheKey
for it.@dynamicMemberLookup
wrapper that adds setters - this kind of works, but it's very error prone at runtime + it messes up with the cache keys for nested types, so it looks unreliable.true
- this appears to works, but it would be great if it was possible to configure that from the codegen config or custom directive (not producing local cache mutation). We would like to avoid using a fork for the long term, because we will have to constantly sync it with the main repo changes.Describe the solution you'd like
Add the ability, via codegen config or some custom directive or some other way, to enable full mutability to any type within any query.
The text was updated successfully, but these errors were encountered: