Apollo Cache Router
Installation
npm install --save-dev apollo-cache-router
Usage
import { InMemoryCache } from 'apollo-cache-inmemory';
import ApolloCacheRouter from 'apollo-cache-router';
import { hasDirectives } from 'apollo-utilities';
const netCache = new InMemoryCache();
const localCache = new InMemoryCache();
const cache = ApolloCacheRouter.override(
ApolloCacheRouter.route([netCache, localCache], document => {
if (hasDirectives(['client'], document)
|| getOperationAST(document).name.value === 'GeneratedClientQuery') {
return [localCache];
} else {
return [netCache];
}
}),
{
reset: () => {
return netCache.reset();
}
}
);
Logging
If you want log cache access and errors please check apollo-cache-logger
License
Copyright © 2018 SysGears LTD. This source code is licensed under the MIT license.