apollographql / apollo-utils

Monorepo of common utilities related to Apollo and GraphQL
MIT License
36 stars 11 forks source link

KeyvAdapter v5 type support #459

Open reggermont opened 2 months ago

reggermont commented 2 months ago

Related to https://github.com/apollographql/apollo-utils/issues/457

TypeScript returns the following error:

Argument of type 'Keyv' is not assignable to parameter of type 'Keyv<string, Record<string, unknown>>'.
  Type 'Keyv' is missing the following properties from type 'Keyv<string, Record<string, unknown>>': once, getMaxListeners, rawListeners, listenerCount, and 3 more.ts(2345)
kdybicz commented 2 months ago

got blocked by same issue

sebastiancretu commented 1 month ago

here too

simonjamois commented 3 weeks ago

same here with this issue

jaredwray commented 3 weeks ago

Are you all still seeing this? If so, can I get an example so that we can get this fixed? Make sure you are at the latest as we added in additional support recently.

simonjamois commented 3 weeks ago

Sure ! I am in a strapi v5 configuration, where the graphql plugin is used, here are the specs :

import { KeyvAdapter } from "@apollo/utils.keyvadapter";
import { ErrorsAreMissesCache} from "@apollo/utils.keyvaluecache";
import Keyv from 'keyv';

export default ({ env }) => ({
  graphql: {
    config: {
      endpoint: "/graphql",
      shadowCRUD: true,
      playgroundAlways: true,
      depthLimit: 20,
      amountLimit: 100,
      defaultLimit: 10,
      maxLimit: 200,
//highlight begin
      apolloServer: {
        tracing: true,
        introspection: true,
        cache: 
        new ErrorsAreMissesCache(
          new KeyvAdapter(
          new Keyv(env("REDIS_URL"),{
            namespace:'apollo-cache',
            ttl: 3600 * 1000 //1 hour TTL
          })
            )
          ) 
//highlight end

Where typescript says : Argument of type 'Keyv<any>' is not assignable to parameter of type 'Keyv<string, Record<string, unknown>>'. Type 'Keyv<any>' is missing the following properties from type 'Keyv<string, Record<string, unknown>>': getMaxListeners, rawListeners, listenerCount, prependListener, and 2 more.

Versions are : keyv@5.1.2 @keyv/redis@3.0.1 @apollo/utils.keyvadapter@3.1.0 @apollo/utils.keyvaluecache3.1.0

jaredwray commented 2 weeks ago

@simonjamois - thanks and we are looking into this.

chrisllontop commented 2 weeks ago

@simonjamois Do you have a repo where I can check out the error? I tried to reproduce it but couldn’t.

simonjamois commented 2 weeks ago

The error seems fixed ! Just needed to update @apollo/utils.keyvadapter@3.1.0 > @4.0.0 to allow the module to sync with keyv@5.1.2 Thanks a lot ;)