Created
July 21, 2020 21:05
-
-
Save mlg87/398d468f3b4295e03b8ddbd539074e2a to your computer and use it in GitHub Desktop.
Using Apollo Client for global state management code samples - src/client.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/client.ts | |
import { InMemoryCache } from 'apollo-cache-inmemory'; | |
import balloonDefaultCacheValues from './Balloon/defaults'; | |
import { setSelectedBalloonMutationResolver } from './Balloon/mutations'; | |
import balloonSchema from './Balloon | |
const cache = new InMemoryCache(); | |
export const client = new ApolloClient({ | |
... | |
cache, | |
resolvers: { | |
Mutation: { | |
setSelectedBalloon: setSelectedBalloonMutationResolver | |
} | |
}, | |
typeDefs: [balloonSchema] | |
}); | |
// init cache | |
cache.writeData({ | |
data: { | |
...balloonDefaultCacheValues | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment