apollo-feature-requests
apollo-feature-requests copied to clipboard
Make Client and Cache writeFragment APIs consistent
The Problem
The cache writeFragment API returns a ref to the created or modified object. The client API is similar in every respect, but fails to return the result of the call of the same name into the cache. This makes writing general cache manipulation logic that is fungible between client and mutation update logic more difficult than it needs to be.
The Solution
Store the cache.writeFragment result in a local variable, and return it after subscriptions have been notified.
Why is it better?
With common behaviour it's then possible to write cache manipulation functions that work either with the cache or with the client.