0
TL;DR: In Apollo client, how can I create client mutations usable with useMutation
now that local resolvers are removed? (useful for debug, abstraction, reusability…)
Long version:
I’m learning how to use Apollo client to deal with a local nested state. For now, I’m using something like:
client.writeQuery({
query: IS_LOGGED_IN,
data: {
isLoggedIn: false,
},
});
in order to change the value in the cache. This is nice as it is quite quick to write inside a component, but it has multiple downsides:
- It is harder to share the logic between multiple components, unless I create a function that I can share…
- …but even with a function, the integration with the dev tools seems really bad, as it is NOT considered as a mutation. In particular, I have no history available etc…
- If later on I decide to move the local state in another server, I need to rewrite basically all the data-fetching part of the application
In order to avoid these issues, I wanted to define a "client mutation", is order to be able to use useMutation
like to be agnostic of whether the mutation is run locally or on the server… In older version of GraphQL, this was, if my understanding is correct, possible using local resolvers (see for instance this example). But this has been deprecated… what is the new way of doing that?
Actually, the deprecated status of local resolvers is not even clear… so I’m lost, are they really deprecated?