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.

[3.0-beta] SSR's getDataFromTree(): queries resolved from cache have networkStatus set to loading

See original GitHub issue

Intended 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:

  1. git clone git@github.com:shYkiSto/apollo-client-beta-3-ssr.git
  2. cd apollo-client-beta-3-ssr && npm install && npm run start
  3. open http://localhost:3000/

or, SSR with Next.js found here: https://github.com/shYkiSto/apollo-client-beta-3-ssr/tree/next-js:

  1. git clone --branch next-js git@github.com:shYkiSto/apollo-client-beta-3-ssr.git
  2. cd apollo-client-beta-3-ssr && npm install && npm run dev
  3. open http://localhost:3000/
  4. 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
TimonVScommented, Jul 15, 2020

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.

2reactions
shYkiStocommented, Aug 5, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

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