Switch to improved InMemoryCache from Apollo Client 3
As of Apollo Client 3.0, the
InMemoryCacheclass is provided by the@apollo/clientpackage. No additional libraries are required.
https://www.apollographql.com/docs/react/caching/cache-configuration/
This allows us to drop the dependency on apollo-cache-inmemory.
Further, the new InMemoryCache class provides typePolicies, which allows things like converting dates from strings to JS Date objects, so this PR enables:
# apolloConfig.js, included via apollo.clientConfigs.default in nuxt.config.js
const inMemoryCacheOptions = {
typePolicies: {
Post: {
fields: {
createdAt: {
read(createdAt) {
return new Date(createdAt)
},
},
},
},
},
}
export default (context) => {
return {
inMemoryCacheOptions
}
}
(The above is possible already, but requires importing and initializing the new InMemoryCache manually.)
I think the tests are failing on master? So it's hard to know if this change is okay, I guess.
Well, FWIW, I installed it on my project and it's working fine for my limited use case.
Will this impact https://github.com/nuxt-community/apollo-module/issues/376?
@memic84 I have no idea :). Try it out?
This is totally out of date now.
Not sure what's happening with this project but I don't think anyone is really paying attention.