Skip to content

Commit

Permalink
refactor(cache): support custom cache class (e.g. NextSSRInMemoryCach…
Browse files Browse the repository at this point in the history
…e) (#10)
  • Loading branch information
izumin5210 committed Mar 27, 2024
1 parent e375d19 commit ff4d605
Show file tree
Hide file tree
Showing 5 changed files with 286 additions and 267 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-ladybugs-pull.md
@@ -0,0 +1,5 @@
---
"apollo-client-mux": patch
---

support custom cache class (e.g. NextSSRInMemoryCache)
16 changes: 9 additions & 7 deletions README.md
Expand Up @@ -33,16 +33,18 @@ export default config;

```ts
import { ApolloClient, HttpLink, InMemoryCache } from "@apollo/client";
import { ApolloCacheMux, createApolloLinkMux } from "apollo-client-mux";
import { ApolloCacheMux, withCacheMux } from "apollo-client-mux";

// create ApolloCache
const InMemoryCacheMux = withCacheMux(InMemoryCache);
const yourEndpointCache = new InMemoryCache();
const defaultCache = new InMemoryCache();
const cache = new ApolloCacheMux({
caches: {
yourEndpoint: yourEndpointCache, // <-- use your endopint name
},
defaultCache: defaultCache,
const cache = new InMemoryCacheMux({
mux:{
caches: {
yourEndpoint: yourEndpointCache, // <-- use your endopint name
},
}
// ... options for default cache
});

// create ApolloLink
Expand Down

0 comments on commit ff4d605

Please sign in to comment.