Skip to content

Commit

Permalink
Log when using graphql response cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Oct 12, 2023
1 parent cabbc3c commit 2394a13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion backend/middlewares/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ export const cachePlugin = () =>

const hash = createHash("sha512").update(key).digest("hex")

let usedGraphqlCache = true

const res = await redisify<any>(
async () => next(root, args, context, info),
async () => {
usedGraphqlCache = false
context.logger.info(`Not using graphql response cache for ${key}`)
return next(root, args, context, info)
},
{
prefix: "graphql-response",
expireTime: 300,
Expand All @@ -40,6 +46,9 @@ export const cachePlugin = () =>
logger: context.logger,
},
)
if (usedGraphqlCache) {
context.logger.info(`Used graphql response cache for ${key}`)
}
return res
}
},
Expand Down

0 comments on commit 2394a13

Please sign in to comment.