server side rendering - useQuery fails silently on server
See original GitHub issueFirst 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:
- Created 4 years ago
- Reactions:1
- Comments:10 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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
lol, right 😃
Perhaps 2 days of wrestling with my broken code has made me subconsciously pessimistic to use this kind of wording 😃