question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Loading should not be initially true when the data is provided server-side [reproduction provided]

See original GitHub issue

Intended 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10

github_iconTop GitHub Comments

3reactions
kiyasovcommented, Jul 23, 2020

When will this bug be fixed?

2reactions
daryn-kcommented, Jul 20, 2020

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:

if (!data) return <div>Loading...</div>

there is no error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Update problem when using stateSave with serverSide
I have a datatable with a createdRow function which calls $("td:eq(1)", row).append(...) It works perfectly with stateSave: true, OR with ...
Read more >
DataTables deferred loading with columns option
If you have deferLoading set to positive number along with serverSide: true , it should not request data on the first call, there...
Read more >
WebDataGrid and first row selection (ServerSide) - Infragistics
For me it is essential to load the details of the first GridRow and populate the relative Ajax Panel. I can also loading...
Read more >
load Scheduler Docs - DHTMLX Documentation
In the auto-loading mode Scheduler will load data from server side only if it wasn't loaded yet. So data that was loaded, will...
Read more >
Server-side rendering - Apollo GraphQL Docs
Initializing Apollo Client · You provide ssrMode: true . This prevents Apollo Client from refetching queries unnecessarily, and it also enables you to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found