-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
previousData is lost when useLazyQuery's executor is called #7396
Comments
@benjamn any news on this one? Or someway we can help fix this issue? I'll be happy to contribute, if you could point me in the right direction for a fix. According to the following diff, it seems to me, that the test is already covering this, so it seems odd, that previousData is undefined, if the tests actually pass. Or? |
I've take a look at #6603 and look like this is intentional. I think this doesn't different than I'm also interested to see a use case where reset I or @dahjelle could help to contribute this. |
Hmmm. So I looked into this a little bit and I’m a bit confused by the const [execute, {data, previousData, refetch} = useLazyQuery(MY_QUERY);
// in some callback
onFirstEvent(() => {
// Calling the execute function
execute({variables: {id: 1}});
});
onSecondEvent(() => {
// Calling the execute function
execute({variables: {id: 2}});
// Calling the refetch function
refetch({id: 2});
}); Note that the call signatures of the This is a lot of words to say that you can get the desired behavior if you call We’ve been thinking in AC4 of deprecating I have a unit test on this branch, which shows that this is the behavior. |
My initial thought is "no", but could you give an example of what the |
…te is called multiple times Fixes #7396
…te is called multiple times Fixes #7396
…te is called multiple times Fixes #7396
This should now be resolved in |
Intended outcome:
Extraneous calls of the callback returned by
useLazyQuery
should have no effect.Actual outcome:
Calling the callback always sets the
previousData
toundefined
. To avoid this behaviour, the user has to keep track of "has the callback been called already?"How to reproduce the issue:
Here is a codesandbox which should demonstrate the issue in the console tab. There's a variable you can tweak to enable/disable the workaround.
Versions
The text was updated successfully, but these errors were encountered: