jaredpalmer / razzle

✨ Create server-rendered universal JavaScript applications with no configuration
https://razzlejs.org
MIT License
11.11k stars 867 forks source link

Using Apollo Client Cache Rehydration in Razzle with SSR #1901

Open mbzr opened 2 years ago

mbzr commented 2 years ago

❓Question

I am using Apollo Client with Server-side Rendering but it seems Apollo Client's useQuery hooks are never called on the server side with razzle. All the queries are instead only called on the client side.

To solve this in Next.js, I could call the query on server-side like so:

export async function getServerSideProps() {
    const client = initializeApollo()
    const query = await client.query({query: USER_QUERY })
}

Is there a solution to this in razzle?

fivethreeo commented 2 years ago

https://github.com/apollographql/apollo-client/issues/10231