-
Notifications
You must be signed in to change notification settings - Fork 2k
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
✨ Adding generateCacheKey
to ApolloServerPluginResponseCache
to allow for custom cache keys
#6655
Conversation
|
✅ Deploy Preview for apollo-server-docs canceled.Built without sensitive environment variables
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 1c84a40:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also provide at least a brief mention of this parameter in the docs (docs/source/performance/caching.md
). The table in the bottom section seems reasonable. Thanks1
packages/apollo-server-plugin-response-cache/src/ApolloServerPluginResponseCache.ts
Outdated
Show resolved
Hide resolved
packages/apollo-server-plugin-response-cache/src/ApolloServerPluginResponseCache.ts
Outdated
Show resolved
Hide resolved
…luginResponseCache.ts Co-authored-by: David Glasser <[email protected]>
packages/apollo-server-plugin-response-cache/src/ApolloServerPluginResponseCache.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: David Glasser <[email protected]>
packages/apollo-server-plugin-response-cache/src/ApolloServerPluginResponseCache.ts
Outdated
Show resolved
Hide resolved
…luginResponseCache.ts Co-authored-by: Trevor Scheer <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Would you please make an addition to CHANGELOG.md
?
generateCacheKey
to ApolloServerPluginResponseCache
to allow for custom cache keys
- Rename BaseCacheKey and ContextualCacheKey with "Data" on end, since the cache key is a string. - Reintroduce CacheKey(Data) removed in #6655; make the GenerateCacheKeyFunction type be defined in terms of it. Now calls to the `const generateCacheKey` function are type-safe (ie, the second arg is a CacheKeyData rather than unknown). - Describe generateCacheKey hook as a method rather than a field, like the other hooks in Options.
- Rename BaseCacheKey and ContextualCacheKey with "Data" on end, since the cache key is a string. - Reintroduce CacheKey(Data) removed in #6655; make the GenerateCacheKeyFunction type be defined in terms of it. Now calls to the `const generateCacheKey` function are type-safe (ie, the second arg is a CacheKeyData rather than unknown). - Describe generateCacheKey hook as a method rather than a field, like the other hooks in Options.
…for custom cache keys (#6655) Create a new hook (`generateCacheKey`) on the `ApolloServerPluginResponseCache` constructor options which allows users to customize the cache key used by returning their own `string`. The hook receives two arguments: the `requestContext` and an object (`cacheKeyData`) which contains the following properties: `source` `operationName` `variables` `extra` (computed by `options.extraCacheKeyData`) `sessionId` `sessionMode`
- Rename BaseCacheKey and ContextualCacheKey with "Data" on end, since the cache key is a string. - Reintroduce CacheKey(Data) removed in #6655; make the GenerateCacheKeyFunction type be defined in terms of it. Now calls to the `const generateCacheKey` function are type-safe (ie, the second arg is a CacheKeyData rather than unknown). - Describe generateCacheKey hook as a method rather than a field, like the other hooks in Options.
Create a new hook (
generateCacheKey
) on theApolloServerPluginResponseCache
constructor options which allows users to customize the cache key used by returning
their own
string
.The hook receives two arguments: the
requestContext
and an object (cacheKeyData
)which contains the following properties:
source
operationName
variables
extra
(computed byoptions.extraCacheKeyData
)sessionId
sessionMode
Landing in favor of:
#6649
#6428