[3.0-beta] SSR's getDataFromTree(): queries resolved from cache have networkStatus set to loading
See original GitHub issueIntended outcome:
getDataFromTree()
should populate cache with queries data, so that during final render on the server all server-side queries resolve data from cache, instead of firing off network call, and therefore rendering in loading state.
{
"data": "<Query Data Goes here>",
"error": undefined,
"loading": false,
"networkStatus": 7
}
> getDataFromTree() pass - start
> { data: false, error: false, loading: true, networkStatus: 1 }
> { data: true, error: false, loading: false, networkStatus: 7 }
> getDataFromTree() pass - end
> { data: true, error: false, loading: false, networkStatus: 7 }
Actual outcome:
While cache is fulfilled with queries data as expected, the queries themselves have networkStatus set to loading
. Which is not intended outcome, as the data is ready (pulled from cache), and there’s no network request inflight.
{
"data": "<Query Data Goes here>",
"error": undefined,
"loading": true,
"networkStatus": 1
}
> getDataFromTree() pass - start
> { data: false, error: false, loading: true, networkStatus: 1 }
> { data: true, error: false, loading: false, networkStatus: 7 }
> getDataFromTree() pass - end
> { data: true, error: false, loading: true, networkStatus: 1 }
How to reproduce the issue:
You can find reproduction here https://github.com/shYkiSto/apollo-client-beta-3-ssr:
git clone git@github.com:shYkiSto/apollo-client-beta-3-ssr.git
cd apollo-client-beta-3-ssr && npm install && npm run start
- open http://localhost:3000/
or, SSR with Next.js found here: https://github.com/shYkiSto/apollo-client-beta-3-ssr/tree/next-js:
git clone --branch next-js git@github.com:shYkiSto/apollo-client-beta-3-ssr.git
cd apollo-client-beta-3-ssr && npm install && npm run dev
- open http://localhost:3000/
- check server console output to capture query state changes, or disable JS in your browser to assess server-side renderer result
Versions
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.12.0 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/local/bin/yarn
npm: 6.11.3 - /usr/local/bin/npm
Browsers:
Chrome: 77.0.3865.90
Firefox: 69.0.1
Safari: 13.0.4
npmPackages:
@apollo/client: ^3.0.0-beta.25 => 3.0.0-beta.25
@apollo/react-ssr: ^4.0.0-beta.1 => 4.0.0-beta.1
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m not a fan of “me too” comments, but since 3.0 has been released I thought people would like to know that this issue is still present in 3.0.
I’ve verified this is no longer an issue with @apollo/client@3.1.2. Thanks!
See https://github.com/apollographql/apollo-client/pull/6710 for details