Loading should not be initially true when the data is provided server-side [reproduction provided]
See original GitHub issueIntended outcome
new InMemoryCache().restore(window.apolloState || {})
should populate the cache from window.apolloState
. It works with apollo-client
(version 2.6.x), but not with @apollo/client
.
Actual outcome
new InMemoryCache().restore(window.apolloState || {})
doesn’t populate the cache, it’s empty. By the way, there is no any problem with server and server-side rendering. The problem is in client side. It doesn’t restore the cache. We are getting the warning from React because of that.
Warning: Text content did not match.
Server: "Success!sunt aut facere repellat provident occaecati excepturi optio reprehenderit"
Client: "Loading..."
How to reproduce
Here are demos:
Github: https://github.com/daryn-k/apollo-client-3-ssr-demo.git
[link]
CodeSandBox: https://codesandbox.io/s/optimistic-dust-wu0u6
[link]
npm install
npm run client
npm run server
npm start
You can comment and uncomment the lines with 🕷 and ✅ and clearly see how it works with old version 2.6.x and doesn’t work with the 3.x.
./src/client.js ./src/server.js
import { ApolloClient } from '@apollo/client' // 🕷 It doesn't work with @apollo-client
import { InMemoryCache } from '@apollo/client' // 🕷 same here
// import { ApolloClient } from 'apollo-client' // ✅ But it works with apollo-client v2.6.x
// import { InMemoryCache } from 'apollo-cache-inmemory' // ✅ and apollo-cache-inmemory
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:10
Top GitHub Comments
When will this bug be fixed?
Oops… You are absolutely correct. Sorry, it’s my bad. Right, there is no second fetch. Give me some time to dig into this problem.
If I write:
there is no error.