Fix Typescript error with caching + new Apollo

Okay, right, I guess the Apollo Server upgrade broke type checking in our weird cache control hacks! This should force them to be compatible!
This commit is contained in:
Emi Matchu 2021-11-26 15:22:01 -08:00
parent c032d4a00b
commit c4e32d92f1

View file

@ -122,7 +122,6 @@ export const plugin = (
willSendResponse(requestContext) { willSendResponse(requestContext) {
const { const {
response, response,
// @ts-ignore: FORK. Don't know enough TypeScript to resolve this!
overallCachePolicy: overallCachePolicyOverride, overallCachePolicy: overallCachePolicyOverride,
} = requestContext; } = requestContext;
@ -133,12 +132,13 @@ export const plugin = (
// Use the override by default, but if it's not overridden, set our // Use the override by default, but if it's not overridden, set our
// own computation onto the `requestContext` for other plugins to read. // own computation onto the `requestContext` for other plugins to read.
const overallCachePolicy = // FORK: I do an `any` cast here to convince Typescript that our
// CacheHint type is compatible with the built-in one.
const overallCachePolicy: Required<CacheHint> | undefined =
overallCachePolicyOverride || overallCachePolicyOverride ||
// @ts-ignore: FORK. Don't know enough TypeScript to resolve this! ((requestContext.overallCachePolicy = computeOverallCachePolicy(
(requestContext.overallCachePolicy = computeOverallCachePolicy(
hints hints
)); )) as any);
if ( if (
overallCachePolicy && overallCachePolicy &&