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

Incompatible Typescript Cache type when using createInMemoryCache #2905

Closed
aidenfoxx opened this issue Jul 4, 2023 · 4 comments · Fixed by #3000
Closed

Incompatible Typescript Cache type when using createInMemoryCache #2905

aidenfoxx opened this issue Jul 4, 2023 · 4 comments · Fixed by #3000
Assignees

Comments

@aidenfoxx
Copy link

aidenfoxx commented Jul 4, 2023

Describe the bug

When using the latest @graphql-yoga/plugin-response-cache plugin, providing a manually initialized createInMemoryCache cache instance causes a Typescript error:

error TS2322: Type 'import("/workspace/node_modules/@envelop/response-cache/typings/cache").Cache' is not assignable to type 'Cache'.
  The types returned by 'get(...)' are incompatible between these types.
    Type 'PromiseOrValue<ExecutionResult<ObjMap<unknown>, ObjMap<unknown>>>' is not assignable to type 'Promise<ExecutionResult<Record<string, unknown>, ResponseCachePluginExtensions>>'.
      Type 'ExecutionResult<ObjMap<unknown>, ObjMap<unknown>>' is missing the following properties from type 'Promise<ExecutionResult<Record<string, unknown>, ResponseCachePluginExtensions>>': then, catch, finally, [Symbol.toStringTag]

Prior versions of the plugin (1.4.0) did not cause this error.

Your Example Website or App

https://codesandbox.io/p/sandbox/laughing-keldysh-ffhp3k?file=%2Findex.ts%3A4%2C20

Steps to Reproduce the Bug or Issue

Create a Typescript instance of Yoga using the useResponseCache plugin, with the cache option set to a cache instance created with createInMemoryCache.

Expected behavior

The server should start normally.

Screenshots or Videos

No response

Platform

Typescript

Additional context

No response

@0-don
Copy link

0-don commented Jul 27, 2023

yes having the same problem

@Aurumdev952
Copy link

Aurumdev952 commented Sep 15, 2023

I'm having the same problem using createRedisCache({ redis }) from the example in the docs
"@envelop/response-cache-redis": "^3.3.0", "@graphql-yoga/plugin-response-cache": "^2.1.1", "ioredis": "^5.3.2",

@gthau
Copy link
Contributor

gthau commented Sep 19, 2023

A possible workaround while it's being fixed is:

const cache = createInMemoryCache() as UseResponseCacheParameter['cache'];

@EmrysMyrddin
Copy link
Collaborator

You can try @graphql-yoga/plugin-response-cache@2.1.2-rc-20230920111722-2d9abd25 preview version if you want to verify the fix is working.

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

Successfully merging a pull request may close this issue.

5 participants