-
Notifications
You must be signed in to change notification settings - Fork 109
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
Allow "cache-and-network" fetch policy with useQuery again #165
Conversation
…cache-and-network" fetch policy.
Took a look at the CI results - I'm just realised that this repo has (type errors, click to expand)
If someone has pointers how to resolve those, that'd be great - otherwise maybe a workaround for now could be just to set the Nice one, thank you :) |
When I opened PR #169 just now I took the easy way and upgraded to a recent TypeScript version. Seems like something else changed in apollo-client and this looks like the easiest fix. |
Sounds good, thanks for taking a look! Guess this PR can be closed then? (cc #163) |
Fixed in version 0.5.0. |
Excellent, thanks a lot @trojanowski and @sgoll! |
In
[email protected]
, thecache-and-network
fetch policy has been removed from theFetchPolicy
type, as documented here: https://github.com/apollographql/apollo-client/blob/master/CHANGELOG.md#apollo-client-260-1This results in type errors in any project that tries to use the
cache-and-network
fetch policy withuseQuery
using[email protected]
(currently the latest release). To be clear, this very simple (valid!) use-case now results in a type error:It also results in the following type errors in the project:
(7 type errors, click to expand...)
This issue has actually been reported here: apollographql/apollo-client#4849
The fix is to simply change the
QueryOptions
type toWatchQueryOptions
, asuseQuery
useswatchQuery
(which allows thecache-and-network
fetch policy), and notquery
(which doesn't).This exact change is implemented in the commit 184a7b5 (check this diff to look at the actual code changes!)
As a separate commit, I also ran
npm run format
. I initially did this to ensure that I did not introduce new style errors, but I actually found style errors in unrelated files. I hope this is not too controversial to add, if not I can revert/rebase.When running
npm run check-typings
, I now only get 2 type errors, none of which are related to the fetch policy, and actually seem completely unrelated to the project:(2 type errors, unrelated to this change, click to expand...)
Anyway, hope this is useful for anyone who accidentally upgraded to
[email protected]
& broke their TypeScript projects! :)