Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

SSR: instance.fetchData() does not resolve #2136

Closed
freder opened this issue Jun 26, 2018 · 3 comments
Closed

SSR: instance.fetchData() does not resolve #2136

freder opened this issue Jun 26, 2018 · 3 comments

Comments

@freder
Copy link

freder commented Jun 26, 2018

hi,

I am trying to implement SSR for an application, but getDataFromTree never resolves, because instance.fetchData() in getPromisesFromTree never resolves (nor is there an error).

I'm using the simplest possible setup: rendering a single component with a single (simple) query.

obviously everything works fine in the browser.

npm ls --depth=1 | ag apollo
├─┬ [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ ├── [email protected] deduped
│ ├── [email protected] deduped
├─┬ [email protected]
│ ├── [email protected] deduped
├─┬ [email protected]
│ └── [email protected] deduped
├─┬ [email protected]
│ ├── [email protected] deduped
│ └── [email protected]
├─┬ [email protected]
│ └── [email protected] deduped
├── [email protected]
│ ├── [email protected]
│ ├── [email protected]
├─┬ [email protected]
@freder
Copy link
Author

freder commented Jun 26, 2018

made a stripped down example: https://github.com/freder/react-apollo-2136

seems like, as long as I only use the http link, it works. but now it looks like this is happening, as well: #1361logging reveals that the component gets rendered twice. the first time it has received the data already, the second one is in loading state:

{ variables: {},
  refetch: [Function],
  fetchMore: [Function: bound ],
  updateQuery: [Function: bound ],
  startPolling: [Function: bound ],
  stopPolling: [Function: bound ],
  subscribeToMore: [Function: bound ],
  loading: false,
  networkStatus: 7,
  error: undefined,
  allItems:
   [ { id: '11111', __typename: 'Item' },
     { id: '22222', __typename: 'Item' } ] }

{ variables: {},
  refetch: [Function],
  fetchMore: [Function: bound ],
  updateQuery: [Function: bound ],
  startPolling: [Function: bound ],
  stopPolling: [Function: bound ],
  subscribeToMore: [Function: bound ],
  loading: true,
  networkStatus: 1,
  error: undefined }

<span data-reactroot="">no allItems</span>

@benjamn
Copy link
Member

benjamn commented Nov 15, 2018

The implementation of getDataFromTree has changed substantially in [email protected] (the latest version), thanks to #2533. Please try updating!

@rosskevin
Copy link
Contributor

Closing - cleanup.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants