-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[graphcache] mutation update executed twice #653
Comments
The mutation is
I dont know what other information i can provide |
A reproduction is the source of all information, it's very hard for us to make an assumption as to what variables you are calling with, ... For instance why is there no result is it an invalid call or the same call as the second? |
The mutation accepts a string and returns a boolean. And the update is called twice one with result as {} and the second with result {createFriendRequest: true} |
So what I can derive from your current explanation is the following: You have: cacheExchange({
updates: { Mutation: { createFriendRequest: () => smth } },
optimistic: { createFriendRequest: () => ({})},
}) And you are asking why This because even if it's an optimistic update you can have special logic, like adding an item to a list, we allow the user to utilise the updater function for the response they construct in |
Here is a sandbox https://codesandbox.io/s/focused-night-ztnmm I have a console log inside update that you can see it logs twice The only difference from my case is in sandbox case both result and args are null on first execution |
Thanks for the reproduction @zenios that's appreciated, it had to do with the fact that the mutation had no selectionset, there's a fix PR up! |
You are welcome |
Fixed in Graphcache 2.3.0, https://github.com/FormidableLabs/urql/releases/tag/%40urql%2Fexchange-graphcache%402.3.0 |
Hi All
I have a mutation update configured for graphcache that for some weired reason it is executed twice for a single mutation.
One execution with empty result
Second execution with filled result
I did some debugging and i can see that the first execution is done via writeOptimistic before the mutation is send to the server.
And the second is the correct execution done after the results arrives.
I dont have any optimistic configurations in place
The text was updated successfully, but these errors were encountered: