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

@graphql-yoga/plugin-response-cache DX frictions #3035

Closed
Tracked by #2700 ...
klippx opened this issue Sep 29, 2023 · 1 comment · Fixed by #3092
Closed
Tracked by #2700 ...

@graphql-yoga/plugin-response-cache DX frictions #3035

klippx opened this issue Sep 29, 2023 · 1 comment · Fixed by #3092
Assignees

Comments

@klippx
Copy link
Contributor

klippx commented Sep 29, 2023

Is your feature request related to a problem? Please describe.

When writing our custom response cache plugin based on the @graphql-yoga/plugin-response-cache API I noticed the following frictions.

The type Cache is not exported

Instead, I had to do this

import type { UseResponseCacheParameter } from '@graphql-yoga/plugin-response-cache';
type Cache = UseResponseCacheParameter['cache'];

hashSHA256 is not exposed

I wanted to write my own buildResponseCacheKey, but I only want to add an extra item to the array of the default implementation and also modify the cache key to start with a certain pattern. For the checksum, I still want to use hashSHA256() which I think is a clever implementation that is compatible with both bun and node.

Instead, I had to copy the code for hashSHA256.

The docs are wrong

https://the-guild.dev/graphql/yoga-server/docs/features/response-caching#using-schema-directive-cachecontrol

Here it says to do

import { cacheControlDirective } from '@graphql-yoga/plugin-response-cache'

This doesn't work, you have to do

import { cacheControlDirective } from '@envelop/response-cache';

which is a transitive dependency even.

A clear and concise description of what you want to happen

The type Cache is not exported

I want to do

import type { Cache } from '@graphql-yoga/plugin-response-cache';

hashSHA256 is not exposed

Ideally, I want to do:

import { hashSHA256 } from '@graphql-yoga/plugin-response-cache';

But actually, it needs to be exposed from here for that to work:

import { hashSHA256 } from '@envelop/response-cache';

I would rather not import from transitive dep @envelop/response-cache in userland, I prefer first option to import from @graphql-yoga/plugin-response-cache

The docs are wrong

I want to do as the docs says:

import { cacheControlDirective } from '@graphql-yoga/plugin-response-cache'
@JWhist
Copy link

JWhist commented Oct 18, 2023

+1 would like to see Cache interface exported
v5.0.0
Calling createInMemoryCache() leads to an error of Exported variable 'responseCache' has or is using name 'Cache' from external module "***********/node_modules/@graphql-yoga/plugin-response-cache/typings/index" but cannot be named.ts(4023)

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.

3 participants