apollo-client: @client(always:true) doesn't work 🐛
Intended outcome: As documented here, I expect my local queries resolvers to always run.
Actual outcome: They never run. 😕
How to reproduce the issue: https://codesandbox.io/s/wom5lv5owl
Versions
"dependencies": {
"apollo-cache-inmemory": "1.5.1",
"apollo-client": "2.5.1",
"apollo-link-http": "1.5.14",
"apollo-link-ws": "1.0.17",
"graphql": "14.2.0",
"graphql-tag": "2.10.1",
"react": "16.8.3",
"react-apollo": "2.5.3",
"react-dom": "16.8.3",
"react-scripts": "2.1.8"
},
Please let me know if you need extra info or if I could do anything to help.
Thanks! 💙
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 33 (6 by maintainers)
Commits related to this issue
- Avoid overriding cache-and-network fetchPolicy when refetching. Should help with the problem reported by @supercranky in this comment: https://github.com/apollographql/apollo-client/issues/4636#issue... — committed to apollographql/apollo-client by benjamn 5 years ago
- Avoid overriding cache-and-network fetchPolicy when refetching. Should help with the problem reported by @supercranky in this comment: https://github.com/apollographql/apollo-client/issues/4636#issue... — committed to apollographql/apollo-client by benjamn 5 years ago
- Preserve cache-and-network fetchPolicy when refetching. (#4840) Should help with the problem reported by @supercranky in this comment: https://github.com/apollographql/apollo-client/issues/4636#issu... — committed to apollographql/apollo-client by benjamn 5 years ago
Closing since we just published the final version of
apollo-client@2.6.0
to npm, including some improvements to the functionality discussed in this issue. While there may still be related issues that are worth addressing, we are happy to continue those discussions in new issues. SeeCHANGELOG.md
if you’re curious about the other changes in this release.“always:true” should mean always as in always 😄
Still an issue.
@hwillson @benjamn can someone please follow up? I’m also experiencing issues with this.
resolvers only seem to run for preloading values in the cache and not 100% of the time.
I tried out 2.6.0-beta.2 and in my use case (running a query offline)
@client(always:true)
is still not triggering the local resolver, it’s just reading directly from the cache. Let me see if I can put together an example of thisAs @hwillson indicated above, this problem should be fixed if you update
apollo-client
to version 2.6.0-beta.2 (just released): https://codesandbox.io/s/q7n4z9zp96We’re not quite ready to release
apollo-client@2.6.0
officially, but that will happen faster if folks can help us test the beta versions. 🙏seems like, it still isn’t resolved !
the resolvers are only called the first time and never again.
for the time being I using a similar approach to @supercranky 's cachebust hack…
but its so ugly !
Ohh sorry! I hit the wrong button hehe
Still an issue with
"apollo-client": "2.6.2"
…The error is still reproduced with latest client https://codesandbox.io/s/alwaystrue-0c0h0
@supercranky Let’s continue the discussion of offline refetches in https://github.com/apollographql/apollo-client/pull/4840 (warning: that change may not be safe for 2.6.0, given the current release candidate status, but could land soon afterward).
Made a new example with some cache busting (added an unused counter variable to the query) https://codesandbox.io/s/1vx1nn7m7q
This works (even offline), so I’m guessing that there is some kind of memoization going on in either react-apollo or the apollo client
@nuragic Can you re-open please? I mean it’s still an issue
Also facing this using a mixed schema (remote and local)
Does trigger the first time, once gets cached it doesn’t execute the resolver anymore.
This may be an issue with putting the
@client(always: true)
directive on a field that has its own selection set, rather than leaf fields, though I was under the impression both approaches should work:We (@hwillson and I) will investigate!