module.exports = {
"endpoint": "/graphql",
"shadowCRUD": true,
"playgroundAlways": false,
"depthLimit": 7,
"amountLimit": 200,
"shareEnabled": false,
federation: false,
apolloServer: {
tracing: 'production' !== strapi.config.environment ? true : false,
// persistedQueries: { ttl: 10 * MAX_AGE }, // we set this to be a factor of 10, somewhat arbitrary
// cacheControl: { defaultMaxAge: MAX_AGE },
plugins: [
apolloServerPluginResponseCache({
shouldReadFromCache,
shouldWriteToCache,
extraCacheKeyData,
sessionId,
}),
injectCacheControl()
]
},
redisCacheClient: cache
}
// does not work all the time
async function shouldReadFromCache(requestContext) {
if ('IntrospectionQuery' == requestContext.operationName) return false;// graphql ping ignore
// return true;
if (cacheQueryNames.includes(requestContext.operationName)) {
const expired = await cacheExpired(requestContext);
console.debug("shouldReadFromCache:", requestContext.operationName, 'expired?', expired);
return !expired;
}
console.debug("readCache nocache:", requestContext.operationName);
return false;
}
my sample code uses strapi: