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

useQuery does not run on the client when ssr=false #3418

Closed
baldurh opened this issue Aug 27, 2019 · 3 comments
Closed

useQuery does not run on the client when ssr=false #3418

baldurh opened this issue Aug 27, 2019 · 3 comments

Comments

@baldurh
Copy link

baldurh commented Aug 27, 2019

Intended outcome:

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

Actual outcome:

It is not being run. It seems it is hydrating with null and is therefore not firing the query on the client on load. This works using the <Query> component and there are no results for this query in the hydration data from the server.

How to reproduce the issue:

Haven’t created a repro yet. I can do that if you’re not able to surface the bug.

Version

System:
    OS: macOS 10.14.4
  Binaries:
    Node: 11.14.0 - /usr/local/bin/node
    Yarn: 1.16.0 - ~/code/monorepo/src/js/web/node_modules/.bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 76.0.3809.100
    Firefox: 68.0
    Safari: 12.1
  npmPackages:
    @apollo/react-components: 3.0.1 => 3.0.1 
    @apollo/react-hooks: 3.0.1 => 3.0.1 
    @apollo/react-ssr: 3.0.1 => 3.0.1 
    apollo: 2.17.3 => 2.17.3 
    apollo-cache-inmemory: 1.6.2 => 1.6.2 
    apollo-client: 2.6.3 => 2.6.3 
    apollo-link: 1.2.12 => 1.2.12 
    apollo-link-error: 1.1.11 => 1.1.11 
    apollo-link-http: 1.5.15 => 1.5.15 
    apollo-link-rest: 0.7.3 => 0.7.3 
@hwillson
Copy link
Member

hwillson commented Sep 6, 2019

This should be fixed in React Apollo 3.1.0, but let us know if not. Thanks!

@hwillson hwillson closed this as completed Sep 6, 2019
@cenoura
Copy link

cenoura commented Jan 16, 2020

@hwillson I was able to reproduce the error using both <Query ssr={false}> component and useQuery(QUERY, {ssr: false}).

Packages versions:

@apollo/react-common@3.1.3
@apollo/react-components@3.1.3
@apollo/react-hooks@3.1.3
@apollo/react-ssr@3.1.3
apollo-cache-inmemory@1.6.5
apollo-cache@1.3.4
apollo-client@2.6.8
apollo-link-http-common@0.2.15
apollo-link-http@1.5.16
apollo-link-persisted-queries@0.2.2
apollo-link-schema@1.2.4
apollo-link@1.2.13

@benjie
Copy link

benjie commented Jun 4, 2020

We're seeing this issue too, I've built a small reproduction and filed a new issue about it: #4003

If you're facing this issue, please add a 👍 reaction to #4003

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

4 participants