Apollo Client 3 UseMutation data empty object

I’m attempting to use Apollo Client 3 as a local state solution. However, I’m having some trouble using the UseMutation hook.

The following repository contains my code apollo-use-query repo with a simple container that displays user data.

Whilst debugging the update function (updateUserCache) of the useMutation hook.

I noticed that the data object was not providing the updated activeUser in the updateUserCache parameter and rather providing an empty object. Why is the data object parameter empty?

I also noticed that the data object is returned with the correct data when using the deprecated local resolvers here:

However, these are reaching EOL so I don’t want to use them in my repo. Am I missing a type policy in my cache that resolves this in the new AC3 implementation?

@aancer-rca Please see this PR for an explanation of the issue:

In short, Apollo Client no longer supports @client mutations with useMutation. We recommend using either writeQuery / writeFragment directly, or reactive variables.

Thanks @hwillson! Much appreciated!

1 Like