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.

server side rendering - useQuery fails silently on server

See original GitHub issue

First let me say I absolutely love your work, it’s very helpful in writing clean functional code.

That out of the way I’m trying to get server side rendering to work and I’m using 0.3.0 of your package which is working fine on the browser. The problem is useQuery returns

{ relay:
   { environment:
      RelayModernEnvironment {
        configName: undefined,
        _operationLoader: undefined,
        _network: [RelayNetworkLayer],
        _publishQueue: [RelayPublishQueue],
        _scheduler: null,
        _store: [RelayModernStore],
        unstable_internal: [Object],
        __setNet: [Function],
        DEBUG_inspect: [Function] },
     variables: { somevariable: 'somevalue' } },
  error: null,
  props: null,
  retry: null,
  cached: false }

on the server and RelayNetworkLayer that I passed into the environment doesn’t get invoked. I tried the exact same environment, query and variables using react-relay’s (4.0.0) QueryRenderer on server side and it worked so it must be the useQuery that is at fault here.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
morryscommented, Jun 16, 2019

I understand you 😃 I have already verified the optimizations that make useQuery and ssr work better. Because of Murphy’s law, I prefer to check better haha

For any questions you can contact me on Twitter (link in the profile) or on slack graphql.slack.com

1reaction
webicancommented, Jun 16, 2019

lol, right 😃

Perhaps 2 days of wrestling with my broken code has made me subconsciously pessimistic to use this kind of wording 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Server-side rendering - Apollo GraphQL Docs
Server -side rendering (SSR) is a performance optimization for modern web apps. It enables you to render your app's initial state to raw...
Read more >
Server-side Rendering | urql Documentation
The ssrExchange must be initialized with the isClient and initialState options. The isClient option tells the exchange whether it's on the server- or ......
Read more >
Does useQuery run on server-side rendering? - Stack Overflow
Since the first rule of hooks is that they must only be called at the top level (client-side), you cannot use them in...
Read more >
NextJS and React-Query - Server Side fetching of data - SSR
In this quick tutorial you'll learn how to fetch data on the server with React-Query and NextJS. This is great as the data...
Read more >
NextJS / React SSR: 21 Universal Data Fetching Patterns ...
If we miss that second step, the re-hydration of the client will fail as the server-rendered html will differ from the first client-side...
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