-
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
(apollo-utilities): unstable stringify key #2869
(apollo-utilities): unstable stringify key #2869
Conversation
ensure the key generated is the same even if the object keys are not the same order
@gdi2290 interesting! Would you be able to add a testing showing where this fixes a bug? |
@jbaxleyiii yeah when I get time I can setup some tests and fix the type issue after getting up the repo correctly. We ran into this problem on Tipe when our variable was in a different order JSON.stringify({id: 'id', project: 'project'}) === JSON.stringify({project: 'project', id: 'id'}) |
I think the changes to storeUtils.ts that are conflicting this PR actually also need the fixes applied to them: apollo-client/packages/apollo-utilities/src/storeUtils.ts Lines 194 to 217 in 6de2e1b
|
@jbaxleyiii can you take over this PR. I can't find the time to work on it |
@@ -216,6 +218,7 @@ export function getStoreKeyName( | |||
let completeFieldName: string = fieldName; | |||
|
|||
if (args) { | |||
const stringifiedArgs: string = stringify(args); | |||
const stringifiedArgs: string = JSON.stringify(args); |
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 line should be removed (rebase/merge problem)
@@ -16,7 +16,7 @@ import { | |||
NameNode, | |||
} from 'graphql'; | |||
|
|||
import * as stringify from 'json-stable-stringify'; | |||
import stringify from 'fast-json-stable-stringify'; |
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'm cleaning this PR up a bit to get it ready for merging. One quick note here - I've replaced json-stable-stringify
with fast-json-stable-stringify
instead, since it's 1/4 the size, faster, and it covers everything we need it for.
Increasing ever so slightly, to accommodate `fast-json-stable-stringify`.
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.
Thanks for kick starting this PR @gdi2290! We should be all set here, so LGTM!
LGTM |
ensure the key generated is the same even if the object keys are not
the same order
Checklist: