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

useQuery(..., { ssr: false }) never requests data #4003

Open
benjie opened this issue Jun 4, 2020 · 0 comments
Open

useQuery(..., { ssr: false }) never requests data #4003

benjie opened this issue Jun 4, 2020 · 0 comments

Comments

@benjie
Copy link

benjie commented Jun 4, 2020

See #3418 for this previously reported (with more users seeing the issue); this issue has a reproduction using the error template.

Intended outcome:

useQuery(query, { ssr: false }) runs on the client side on page load in an SSR application.

Actual outcome:

The GraphQL request is never issued to the server and loading never becomes false.

Object
  called: true
  client: ApolloClient {defaultOptions: {…}, resetStoreCallbacks: Array(0), 
  clearStoreCallbacks: Array(0), link: ApolloLink, cache: InMemoryCache, …}
  data: undefined
  fetchMore: ƒ (fetchMoreOptions)
  loading: true
  networkStatus: 1
  refetch: ƒ (variables)
  stale: false
  startPolling: ƒ (pollInterval)
  stopPolling: ƒ ()
  subscribeToMore: ƒ (options)
  updateQuery: ƒ (mapFn)
  variables: {itemId: 13075}
  __proto__: Object

How to reproduce the issue:

Use useQuery(..., { ssr: false }) anywhere, and use SSR.

I've created a reproduction using react-apollo-error-template but I had to downgrade to apollo-client (rather than @apollo/client) because the SSR documentation refers to things that don't seem to be available in @apollo/client yet. This has also required adding a few more dependencies, sorry for the noise - I kept it as minimal as the Apollo SSR documentation would allow me.

https://github.com/benjie/react-apollo-error-template/tree/ssr-false

Version

This is using the reproduction above (npm)

  System:
    OS: Linux 5.3 Ubuntu 18.04.4 LTS (Bionic Beaver)
  Binaries:
    Node: 12.16.2 - ~/.nvm/versions/node/v12.16.2/bin/node
    Yarn: 1.22.4 - ~/.nvm/versions/node/v12.16.2/bin/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v12.16.2/bin/npm
  Browsers:
    Chrome: 83.0.4103.61
    Firefox: 76.0.1
  npmPackages:
    @apollo/react-hooks: ^3.1.5 => 3.1.5 
    @apollo/react-ssr: ^3.1.5 => 3.1.5 
    apollo-cache-inmemory: ^1.6.6 => 1.6.6 
    apollo-client: ^2.6.10 => 2.6.10 
    apollo-link: ^1.2.14 => 1.2.14 

The envinfo script doesn't seem to output any package results in our actual monorepo.

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

1 participant