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

KeyvAdapter v5 type support #459

Open
reggermont opened this issue Aug 28, 2024 · 10 comments
Open

KeyvAdapter v5 type support #459

reggermont opened this issue Aug 28, 2024 · 10 comments

Comments

@reggermont
Copy link

Related to #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
Copy link

kdybicz commented Sep 3, 2024

got blocked by same issue

@sebastiancretu
Copy link

here too

@simonjamois
Copy link

same here with this issue

@jaredwray
Copy link

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
Copy link

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 : [email protected] @keyv/[email protected] @apollo/[email protected] @apollo/utils.keyvaluecache3.1.0

@jaredwray
Copy link

@simonjamois - thanks and we are looking into this.

@chrisllontop
Copy link

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

@simonjamois
Copy link

The error seems fixed !
Just needed to update @apollo/[email protected] > @4.0.0 to allow the module to sync with [email protected]
Thanks a lot ;)

@Cajuteq
Copy link

Cajuteq commented Nov 22, 2024

Hi, not entirely sure it is the exact same issue, but using

"@apollo/utils.keyvadapter": "^4.0.0",
"keyv": "^5.2.1",
"@keyv/redis": "^4.0.1",

I got

Argument of type 'Keyv<any>' is not assignable to parameter of type 'Keyv<string>'.
Types have separate declarations of a private property '_ttl'.

falling back to
"keyv": "5.1.2",
solved the issue, (I didn't tried other versions)

EDIT: the problem did not reappear after merging and bumping keyv up to 5.2.1 so I think the problem may be linked to other apollo settings as well and not that easy to reproduce; types are now Keyv<any>

@jaredwray
Copy link

@chrisllontop ☝️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants