Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await shouldReadFromCache and shouldWriteToCache options #4890

Merged
merged 3 commits into from
Feb 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,9 @@ export default function plugin(
// Note that we set up sessionId and baseCacheKey before doing this
// check, so that we can still write the result to the cache even if
// we are told not to read from the cache.
if (
options.shouldReadFromCache &&
!options.shouldReadFromCache(requestContext)
) {
return null;
if (options.shouldReadFromCache) {
const shouldReadFromCache = await options.shouldReadFromCache(requestContext);
if (!shouldReadFromCache) return null;
}

if (sessionId === null) {
Expand Down Expand Up @@ -235,11 +233,10 @@ export default function plugin(
}
return;
}
if (
options.shouldWriteToCache &&
!options.shouldWriteToCache(requestContext)
) {
return;

if (options.shouldWriteToCache) {
const shouldWriteToCache = await options.shouldWriteToCache(requestContext);
if(!shouldWriteToCache) return;
}

const { response, overallCachePolicy } = requestContext;
Expand Down