Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

0.13.0

Compare
Choose a tag to compare
@darahayes darahayes released this 09 Jan 13:08
· 941 commits to master since this release
7197446

0.13.0

The 0.13.0 release is a release contains a couple of bug fixes, dependency updates and the new ability to configure your own CachePersistor object as requested in #273 and #281.

The CachePersistor is used by the client to persist the Apollo Cache across application restarts. Pass your own instance to override the one that is created by default.

Example:

import { ApolloOfflineClient, createDefaultCacheStorage } from "offix-client";
import { HttpLink } from "apollo-link-http";
import { InMemoryCache } from "apollo-cache-inmemory";
import { CachePersistor } from "apollo-cache-persist";

const link = new HttpLink({ uri: "http://example.com/graphql" });
const cache = new InMemoryCache()

const cachePersistor = new CachePersistor({
  cache,
  storage: createDefaultCacheStorage()
})

const client = new ApolloOfflineClient({
  cache,
  cachePersistor,
  link
});

Note: if using TypeScript, you may need to declare the cachePersistor as follows const cachePersistor = new CachePersistor<object>(...options) or you may experience compiler errors.

This example uses createDefaultCacheStorage to create the default IndexedDB based storage driver.
The storage can be swapped depending on the platform. For example window.localstorage in older browsers or AsyncStorage in React Native.