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 createRedisCache #3048

Open
AdamJHall opened this issue Oct 9, 2023 · 3 comments
Open

Incompatible Typescript Cache type when using createRedisCache #3048

AdamJHall opened this issue Oct 9, 2023 · 3 comments
Assignees
Labels
kind/bug stage/2-failing-test A failing test was created that describes the issue

Comments

@AdamJHall
Copy link

Describe the bug

When using @graphql-yoga/plugin-response-cache plugin, and following the documented example here: https://the-guild.dev/graphql/yoga-server/docs/features/response-caching#external-cache to provide a createRedisCache cache instance causes a Typescript error:

Type 'import("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<Maybe<ExecutionResult<ObjMap<unknown>, ObjMap<unknown>>>>' is not assignable to type 'Promise<ExecutionResult<Record<string, unknown>, ResponseCachePluginExtensions> | undefined>'.
      Type 'undefined' is not assignable to type 'Promise<ExecutionResult<Record<string, unknown>, ResponseCachePluginExtensions> | undefined>'.ts(2322)
index.d.ts(8, 5): The expected type comes from property 'cache' which is declared here on type 'UseResponseCacheParameter'

Your Example Website or App

https://codesandbox.io/p/sandbox/determined-carlos-7qx3nj?file=%2Fsrc%2Fmain.ts%3A32%2C31

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 createRedisCache.

Expected behavior

The server should start without any typescript compilation errors.

Screenshots or Videos

No response

Platform

  • @envelop/response-cache-redis 3.3.2
  • @graphql-yoga/plugin-response-cache 2.2.0
  • graphql-yoga 4.0.5

Additional context

Seems to be similar to: #2905

@EmrysMyrddin EmrysMyrddin self-assigned this Oct 20, 2023
@EmrysMyrddin EmrysMyrddin added stage/2-failing-test A failing test was created that describes the issue kind/bug labels Oct 20, 2023
@sutt0n
Copy link

sutt0n commented Nov 4, 2024

Can confirm, this is still an issue.

@jasonkuhrt
Copy link
Collaborator

jasonkuhrt commented Dec 11, 2024

Repro:

CleanShot 2024-12-11 at 16 27 31@2x

Links:

Next to check:

  • Are types only different b/c of missing dep updates in some chain somewhere
  • If no, what's intended type currently. Then do update, make release, make updates.

@jasonkuhrt
Copy link
Collaborator

jasonkuhrt commented Dec 11, 2024

I have a solution locally based on changing the Envelop plugins. Need access to https://github.com/n1ru4l/envelop to make my PR. I'll check with the team about it tomorrow.

CleanShot 2024-12-11 at 17 02 47@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug stage/2-failing-test A failing test was created that describes the issue
Projects
None yet
Development

No branches or pull requests

4 participants