Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save viniciussbs/af8192a713f6a36f70b976031936b9f1 to your computer and use it in GitHub Desktop.
import ApplicationInstance from '@ember/application/instance';
export function initialize(appInstance: ApplicationInstance): void {
const fastboot = appInstance.lookup('service:fastboot');
const apolloCache = appInstance.lookup('service:apollo').client.cache;
const shoebox = fastboot.get('shoebox');
if (fastboot.get('isFastBoot')) {
shoebox.put('apollo-cache', {
get cache(): unknown {
return apolloCache.extract();
}
});
} else {
const cacheContents = shoebox.retrieve('apollo-cache');
if (cacheContents && cacheContents.cache) {
apolloCache.restore(cacheContents.cache);
}
}
}
export default {
name: 'apollo-cache-shoebox',
initialize
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment