apollo-cache-persist
Apolloでデータフェッチした結果を永続化するためのモジュール 2019年頭には動きがなく、Chromeの拡張ツールも結果がリアルタイムに反映されずに全然使えなそうに見えたが、最近動きが出始めた?
code:初期化の例.tsx
import { persistCache } from 'apollo-cache-persist';
const cache = new InMemoryCache();
// await before instantiating ApolloClient, else queries might run before the cache is persisted
async function init() {
await persistCache({
cache,
storage: window.localStorage as any,
});
}
init();
const client = new ApolloClient({
cache,
link: createHttpLink({
uri: '/graphql',
}),
typeDefs,
resolvers,
});