-
Notifications
You must be signed in to change notification settings - Fork 576
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
Response Cache plugin with small changes for better type-safety #1359
Conversation
🦋 Changeset detectedLatest commit: a0026b7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Benchmark Results
|
The latest changes of this PR are not available as canary, since there are no linked |
const operationIdByRequest = new WeakMap<Request, string>() | ||
|
||
// We trick Envelop plugin by passing operationId as sessionId so we can take it from cache key builder we pass to Envelop | ||
function sessionFactoryForEnvelop({ request }: YogaInitialContext) { |
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.
Because we don't have an access to the context from buildResponseCacheKey
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.
New envelop response-cache plugin is released, I think you can use it and then also change the target branch here to v3
.
312ad00
to
a979e25
Compare
a979e25
to
ce79ebb
Compare
9fbe8e7
to
54a67e6
Compare
ce79ebb
to
a541eb4
Compare
a541eb4
to
b974582
Compare
332b565
to
f64f21f
Compare
0f78875
to
bcc25fa
Compare
const operationId = await buildResponseCacheKey({ | ||
documentString: params.query!, | ||
variableValues: params.variables, | ||
operationName: params.operationName, | ||
sessionId: options.session(params, request), | ||
}) | ||
const cachedResponse = await cache.get(operationId) |
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.
I think for mutation and subscription operations we don't really need to lookup in the cache. However, we would need to already parse the string in order to reliably detect whether the operation is a mutation 🤔.
Maybe a simple regex operation could help here?
0faeebb
to
9fea97a
Compare
fb47eb4
to
cd6403c
Compare
* chore(deps): update actions/checkout action to v3 (#1431) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * chore(deps): update dependency ioredis to v5.2.2 (#1450) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Replace cross-undici-fetch with @whatwg-node/fetch * chore(deps): update dependency vite to v3 * Fix GraphiQL build * Go Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Arda TANRIKULU <[email protected]>
cd6403c
to
a0026b7
Compare
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.
It is the best because I fixed it
See the changesets
https://github.com/dotansimha/graphql-yoga/pull/1359/files
I am open for discussions about passing
params
andrequest
instead ofcontext
insessionId
factory.We need some unit tests for the new
sessionId
factory and to make sureexecute
,validate
or evenparse
are never called before this plugin returns the cached response.Need docs