Apollo (GraphQL)
With
vite-plugin-ssr
we keep control over our app architecture; we can integrate
Apollo GraphQL simply by following its SSR docs.
On a high-level, the SSR integration works like this:
- We fetch the initial data on the server-side. (We do it on the server-side so that the initial data is rendered to HTML.)
- We make the initial data available as
pageContext.initialData
. - We make
pageContext.initialData
available on the browser-side by adding 'initialData'
to passToClient
. - We initialize Apollo GraphQL on the browser-side using
pageContext.initialData
.
Examples