-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
documentTransform
: use optimism
and WeakCache
#11389
documentTransform
: use optimism
and WeakCache
#11389
Conversation
🦋 Changeset detectedLatest commit: baafd93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
size-limit report 📦
|
.api-reports/api-report-core.md
Outdated
// (undocumented) | ||
getStableCacheEntry(document: DocumentNode): { | ||
key?: undefined; | ||
value?: DocumentNode | undefined; | ||
} | undefined; |
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.
The big downside of this PR: this method vanishes. I'm not sure how much we did consider it part of our external API.
@jerelmiller what are your thoughts?
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.
Ah this should be marked as a private method and I think was just an oversight when we released this.
The getCacheKey
option passed to the constructor should be the public API in this case, so this should be fine to remove.
I want to put out a word of caution with this based on a previous experience I had using `wrap. When developing the This change may very well be fine, but I think we need to make sure that we don't inadvertently invalidate the internal cache. I think most of my tests around the document transforms are verifying the operation was sent to the server correctly, but I don't know that I have any test that does something with the in memory cache that would cause it to recompute wrapped functions. Perhaps you can add a case here for that? |
Will do a full review, but chatted in person and decided optimism is fine moving forward. |
package.json
Outdated
"@wry/context": "^0.7.3", | ||
"@wry/equality": "^0.5.6", | ||
"@wry/trie": "^0.4.3", | ||
"graphql-tag": "^2.12.6", | ||
"hoist-non-react-statics": "^3.3.2", | ||
"optimism": "^0.17.5", | ||
"optimism": "^0.18.0-pre.1", |
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.
You can use the stable 0.18.0 version that is now released. This was merged into main
already though so merging main
-> release-3.9
-> this branch should resolve this.
.changeset/polite-avocados-warn.md
Outdated
"@apollo/client": patch | ||
--- | ||
|
||
`print`: use `WeakCache` instead of `WeakMap` |
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.
Perhaps we just need to merge release-3.9
back into this branch? Odd this made it into the diff.
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.
Changes look great! I think some of the weird stuff will get auto fixed by merging release-3.9
into this one, so I'm not concerned.
…nsform-optimism-weakCache
…nsform-optimism-weakCache
This goes one step further than #11388 and swaps a lot of the logic for a call to
optimism
(assuming the version allowing to swap out theCache
class releases soon)Checklist: