We basically had some logic that would allow writes to be incomplete, however, this didn't apply to optimistic results, which would always cause cached fields to be deleted. Furthermore, in production, partial results will always lead to cached values being deleted from the cache.
Instead, we can apply a better heuristic which only triggers the warning when a field is missing from the cache, but always allow writes to continue, no matter whether values are set or not.
This should in theory be safe, since we're moving potential errors over to reading from the cache.
This also adds a change which makes optimistic mutations read previous keys and __typename fields from the cache to complete mutation results from prior cache results. This should tremendously help the developer experience of having to create these functions.
Set of changes
Allow continue to be applied to undefined field values
Include ctx.optimistic in the above check
Update a test accordingly which checks for console.warns
Summary
We basically had some logic that would allow writes to be incomplete, however, this didn't apply to optimistic results, which would always cause cached fields to be deleted. Furthermore, in production, partial results will always lead to cached values being deleted from the cache.
Instead, we can apply a better heuristic which only triggers the warning when a field is missing from the cache, but always allow writes to continue, no matter whether values are set or not.
This should in theory be safe, since we're moving potential errors over to reading from the cache.
This also adds a change which makes optimistic mutations read previous keys and
__typename
fields from the cache to complete mutation results from prior cache results. This should tremendously help the developer experience of having to create these functions.Set of changes
continue
to be applied toundefined
field valuesctx.optimistic
in the above checkconsole.warn
s__typename
from cached values