Cache Not Working With Redis and ApolloServer 4

I’ve upgraded my Apollo Server 2 app to Apollo Server 4 standalone and setup redis for cache. I know my KeyV is working because I tested that separately. No query data is written to my cache. My server.ts has this:

  let keyV: any;
  if (graphqlCacheEnabled === true) {
    keyV = new Keyv(`redis://${redisHost}:${redisPort}`);
  }
  const server = new ApolloServer<MyContext>({
    typeDefs,
    resolvers,
    csrfPrevention: true,
    cache: graphqlCacheEnabled === true ? new KeyvAdapter(keyV) : undefined,
    plugins: [ApolloServerPluginDrainHttpServer({ httpServer })],

And I annotated a type like this:


  type CodeCampYear @cacheControl(maxAge: 240) {
    id: ID!
    codeCampYearId: Int
    codeCampYearTypeId: Int
    name: String
  }

I’ve responded on the related GH issue for anyone who ends up here looking for an answer.