apollo-feature-requests icon indicating copy to clipboard operation
apollo-feature-requests copied to clipboard

Add update option to useSubscription hook

Open mattwahner opened this issue 4 years ago • 0 comments

In the current functionality of the Apollo Client react hooks, the hook useMutation has an option update which can store a callback function to update the cache. The react hook useSubscription on the other hand does not have such an option. Instead, the user would likely need to provide an onSubscriptionData callback, of which grabs the cache through the client provided as an argument to onSubscriptionData.

I believe providing an update option to the useSubscription would help users create clearer cache changing behavior. The behavior of the update option would mimic exactly useMutation's behavior, with the exception that it would be ran every time the subscription received data.

mattwahner avatar May 21 '21 17:05 mattwahner