-
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
3.6.0 Some queries never executing with a conditional skip and overridden fetchPolicy #9635
Comments
I've been wrestling something similar all day. Basically what I've discovered is that if you update an input to one query from a "then" block of another, the dependent query will never work again (even after force killing the app) until the value of notifyOnNetworkStatusChange is toggled. I've seen a lot of posters mention that the notifyOnNetworkStatusChange should be true (and that may be the case), but to alleviate the immediate problem of never getting data, I'd start out by trying to invert that flag. Not sure exactly what the solution is for your particular case (maybe an effect?), but hopefully that toggle operation will unstick you from the "never getting data" problem |
@mversteeg Just in case this helps: |
Yeah I've updated to 3.6.1, but am still observing the problematic behavior with the following (simplified) example: Queries & State:
Create the DSP and update the ID state variable from the "then" block
Then, when trying to run the "getDSP" query, it stays in this state: I haven't pinned down exactly which changes will cause it to work again, but some of those that have caused the switch for me are:
Hope this helps someone! I think for now I'm just going to be looking for a way to chain requests without using that promise block. Maybe a delay would prevent it if this is caused by a race condition |
Save here with v3.6.1 and react 18. In my case the client config is const apolloClient = new ApolloClient({
cache,
connectToDevTools: true,
link,
defaultOptions: {
watchQuery: {
nextFetchPolicy: "cache-only",
},
},
}); and all the query are cancelled (but not the mutations), setting or not the |
v3.6.1 is not working with React Native, queries are not executed. Have to downgrade to v3.5.10 |
Hello I had the same issue with v3.6.0, v3.6.1 and v3.6.2. Reverting to v3.5.10 also fixed the issue for me. |
Thanks to @dmarkow's reproduction, I'm confident my PR #9665 will resolve the original issue. |
@benjamn That alpha seems to fix the problem both in my test repo and production app. Thanks! |
Hello @benjamn, both v3.7.0-alpha.1 and v3.7.0-alpha.2 did not work for me. I retested v3.5.10 just in case and it worked well (I am on react-native). My ApolloClient is setup like this:
|
@saladestomateoignon Can you open a new issue with a reproduction? This issue had a reproduction that's fixed now, so it sounds like your issue must be slightly different. |
@benjamn Confirming that |
@benjamn @saladestomateoignon |
I"m using react@17.0.2 and rn@0.66.4 although I doubt rn is the culprit. Maybe make sure nothing's cached although the js should update on hot reload. Maybe check the @apollo/client package file to verify the version. |
The original reproduction appears to be fixed by |
Intended outcome:
In my example app, clicking a person's name uses
setState
to store their ID, and then runs a second query to find their country and display it. This second query only executes if apersonId
is passed in (usingskip: !personId
).Actual outcome:
In apollo-client 3.4 and 3.5, this works as expected and displays a country. In 3.6, clicking a person's name does nothing.
How to reproduce the issue:
See https://github.com/dmarkow/apollo-default-options-issue. Open the console and try clicking names. One render completes due to the
setState
call, howeverplacesLoading
from the second query remains false and the query never executes.This seems to only happen if I have both
defaultOptions.watchQuery.fetchPolicy
set to anything, and a conditional skip option. If I completely remove thefetchPolicy
setting it works, but then I can't control caching on my queries. It also works if I remove theskip: !personId
option and change the resolver to return an empty list when no personId is passed in.Versions
The text was updated successfully, but these errors were encountered: