Closed codeflyer closed 2 years ago
I think this is already possible. You can check the type of operation and skip it if it is a mutation
Example code:
app.register(cache, {
async skip (self, arg, ctx, info) {
if (info.operation.operation === 'mutation') {
console.log('Mutation detected skipping')
return true
}
return false
},
all: true,
onHit: function (type, fieldName) {
app.log.info({ msg: 'hit from cache', type, fieldName })
}
})
@mcollina Is the above snippet correct? If yes, do you want me to add an example in the repo?
I mean this should be the default implementation.Mutations should always be skipped.
When a mutation is done, the user can add a query in the request.
It will be useful to verify the type of request and skip the cache when is a
mutation
.In this way the user will get always data up to date after a modify action.