Open QiroNT opened 1 year ago
Having the option to define typePolicies
and other InMemory cache optional that require functions would be great
I couldn't get the official Apollo example from above to work, but this works fine now:
read: (name) => {
// Return the cached name, transformed to upper case
return name.toUpperCase()
}
Apollo supports defining
read
&merge
function for fields inInMemoryCache
(https://www.apollographql.com/docs/react/caching/cache-field-behavior), which is critical for advanced caching and custom scalars.But that involves defining functions inside
inMemoryCacheOptions
.As far as I can tell, the functions will be ignored because of the use of
JSON.stringify
in here: https://github.com/nuxt-modules/apollo/blob/1f52586ab7ae3944b0cbfccc01c893ca3c9c8df9/src/module.ts#L104-L114My best thought around solving this would be to provide a hook to register
inMemoryCacheOptions
instead of defining it innuxt.config
, kinds of like how Nuxt does fortitleTemplate
.Hope it could be supported!