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.

getDataFromTree not working (render to Loading...)

See original GitHub issue

_app.js:

this code render <div>Loading…</div>

import withApollo from 'next-with-apollo';
import { ApolloProvider } from '@apollo/react-hooks';
import ApolloClient, { InMemoryCache } from 'apollo-boost';
import { getDataFromTree } from '@apollo/react-ssr'


const App = ({Component, pageProps, apollo}) => (
  <ApolloProvider client={ apollo }>
    <Component { ...pageProps } />
  </ApolloProvider>
);

export default withApollo(function ({initialState}) {

  return new ApolloClient({
    uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn',
    cache: new InMemoryCache().restore(initialState || {})
  });

}, {getDataFromTree})(App, {getDataFromTree});


Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:10

github_iconTop GitHub Comments

2reactions
thaisonnguyenbtcommented, Apr 29, 2020

I changed to use 4.3.0 and it render in server side

With 5.0.0 and 5.0.1, page is rendered at client side with “Loading…”

1reaction
lakshyasharma14commented, Feb 14, 2022

Hi, we had a similar issue where we would get Loading instead of the data. Our problem was that we have a custom _document.js file where we do Stylesheet related stuff. Long story short: the apolloState needs to be passed to the app in case you have a custom _document.js file. @adiyathemighty Do you have any sample code for this, I am facing the same issue that AppTree is not showing the query and thus ApolloState is also null. So the client is not making any calls on the server side but doing it on client-side only.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SSR - Apollo GraphQL Docs
The getDataFromTree function takes your React tree, determines which queries are needed to render them, and then fetches them all. JavaScript.
Read more >
React Apollo SSR getDataFromTree not waiting for query
The issue here is that getDataFromTree is not waiting for my query at all. It simply returns the component with loading: true and...
Read more >
next-with-apollo
I try to totally disable Apollo queries during server render in test mode, so that I can mock them ... getDataFromTree not working...
Read more >
Setting up Apollo GraphQL in Next.js with Server Side ...
However, the biggest downside to client side rendering is poor SEO ... running `getDataFromTree`', error); } // getDataFromTree does not ...
Read more >
Server-side rendering - Apollo GraphQL
Apollo provides two techniques to allow your applications to load ... be getting stale data and you'll have problems with authentication.
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