-
Notifications
You must be signed in to change notification settings - Fork 9
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
useQuery hook returns empty data on first render with cache #6
Comments
This happens because you have set a Is this a behaviour that you agree with or would you prefer an option to disable it? |
I can see your point, but I'm not sure that this assumption holds true in all cases. My take on the polling interval is more making sure the data stays fresh without necessarily having an opinion about how the data is initially fetched given that's what Oh and fwiw my example above might be a little misleading here. The actual code generally uses |
Fair points there. I've decided to remove this behaviour, given that (a) personally I've stopped using polling entirely in my projects, (b) it's easy enough to achieve the same thing in user land, (c) this behaviour isn't documented yet and (d) this library is young enough that probably nobody will mind or even notice. :) I'll keep the issue open until I do. Thanks again for your input! |
…th poll intervals to always make an initial network request on component mount
Fixed in v1.11.2 |
Thanks for making this change! Unfortunately I'm still seeing the same behavior/output above with 1.11.2. That is, on the first render diff --git a/yarn.lock b/yarn.lock
index 10deb7a..9b75498 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -68,7 +68,7 @@ __metadata:
"@typescript-eslint/eslint-plugin": ^4.17.0
"@typescript-eslint/parser": ^4.17.0
add-asset-html-webpack-plugin: ^3.2.0
- apollo-augmented-hooks: ^1.11.1
+ apollo-augmented-hooks: ^1.11.2
apollo-cache: ^1.3.5
apollo-cache-persist: ^0.1.1
babel-loader: ^8.2.2 |
Yep, there was actually a separate bug in there that caused cached data to only be returned on the second render. Fixed it in v1.11.3, thanks for the heads up! |
Works great now. Thanks again for your help! |
I'm running into a certain behavior that does not appear to be intentional. The scenario is that I have a list of events that are fetched with
useQuery
. For this example, the events are already in the cache.Here is the result of me logging the 'data' and 'loading' params on the first two renders:
If I swap out apollo-augmented-hooks for apollo/client, it looks like this:
Here's my call to
useQuery
:The text was updated successfully, but these errors were encountered: