INNER CODE UNIT · TypeScript
initApollo
panaverse/learn-nextjs · nextjs12/step19_fetching_data_ssr_graphql_extra/lib/apollo/index.ts:24
export function initApollo(initialState?: NormalizedCacheObject) {
const client = apolloClient || createApolloClient();
if (initialState != undefined) {
client.cache.restore({
...client.extract(),
...initialState
});
}
if (typeof window === "undefined") {
return client;
}
if (!apolloClient) {
apolloClient = client;
}
return client;
}
export function useApollo(initialState: NormalizedCacheObject) {