Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
context.rendered = () => {
// Same for Apollo client cache
context.apolloState = ApolloSSR.getStates(apolloProvider)
}
resolve(app)
return renderer.renderToString(app).then((renderedApp) => {
// We add the GraphQL state to the SSR state so that we can avoid refetching queries after client load
// Not using GraphQL? Get rid of this.
state.APOLLO_STATE = ApolloSSR.getStates(graphQLProvider);
return {
renderedApp,
app,
};
});
});
beforeNuxtRender(({ nuxtState }) => {
nuxtState.apollo = VueApolloSSR.getStates(apolloProvider);
});
}
async ({ app, router, route, store, ssr, error }) => {
const matchedComponents = router.getMatchedComponents();
try {
await ApolloSSR.prefetchAll(
app.$apolloProvider,
[App, ...matchedComponents],
{
route,
store,
},
);
ssr.bodyAdd = ``;
} catch (err) {
error(err);
}
},
);