-
Notifications
You must be signed in to change notification settings - Fork 915
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
refactor(experimental): use json-stable-stringify
with bigint support for cache keys
#2022
Conversation
…rt for cache keys
Current dependencies on/for this PR:
This stack of pull requests is managed by Graphite. |
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.
Clean! 👌
Merge activity
|
Unfortunately, this has to be backed out. #2014 (comment) |
|
||
function replacer(_: any, value: any) { | ||
if (typeof value === 'bigint') { | ||
return value.toString() + 'n'; |
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.
This makes these a hash collision:
{foo: 1n}
{foo: '1n'}
"fast-stable-stringify": "^1.0.0", | ||
"graphql": "^16.8.0" | ||
"graphql": "^16.8.0", | ||
"json-stable-stringify": "^1.1.0" |
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.
Alright, I'll revisit this ASAP. Are we sure rolling our own hasher is the most efficient way to do this? Would we reuse it anywhere else? Steve shared a scratch-pad approach to forking |
Since the replacer of Making such a low-level helper asynchronous could bubble up the asynchronousnesss all over the place. |
Yeah, I see it as real simple. These stringifiers endeavour to be JSON compatible when that’s the last thing we need. We just need something order-independent, deterministic, and unique. nobody will accept a PR for this. We can however fork |
It would definitely suck. On the other hand we could still make a sync version with a userland implementation of SHA-256. I just don’t know how much slower this would be than the ‘crap out megabytes of strings’ solutions. It would definitely be more space efficient though. Ask me for that story later. |
🎉 This PR is included in version 1.89.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up. |
This PR swaps
fast-stable-stringify
forjson-stable-stringify
for theresolvers' cache key functions.
Adding
bigint
support via thereplacer
option solves theBigInt
parsingbug reported in #1986.
Closes #1986.