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
Sort selections in a stable sort order #2681
Conversation
This will highlight the issue posed on facebook#2675 and nodejs/node#24294
"__typename": "Comment", | ||
"body": { | ||
"text": "<mock-value-for-field-\\"text\\">" | ||
"__typename": "User", |
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 looks like an odd change... 🤔
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 what’s happening is that we’re able to skip more redundant nodes as a result of this change (exactly what I’d expect). I need to look at this more and try it locally to confirm.
@@ -745,12 +750,16 @@ fragment TestFragment on Viewer { | |||
{ | |||
"variables": {}, | |||
"payload": { | |||
"__typename": "Page", |
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 too. 🤔 🤔 🤔
}, | ||
[[], []], | ||
); | ||
return [...scalarsAndLinkedFields, ...rest]; |
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.
Repeatedly creating new arrays like this is incredibly inefficient. Instead, let’s create just two new arrays and partition the elements into them. There’s a helper function partitionArray() (or similar) in RelayParser that we can extract into a module and reuse it for this.
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.
Done in 516ae8c
"__typename": "Comment", | ||
"body": { | ||
"text": "<mock-value-for-field-\\"text\\">" | ||
"__typename": "User", |
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 what’s happening is that we’re able to skip more redundant nodes as a result of this change (exactly what I’d expect). I need to look at this more and try it locally to confirm.
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.
@kassens has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
This looks good to me. Now testing internally. The only update I made was adding the file headers and keeping the old sort behind a |
This fixes an issue that was raised in Node 11, where
sort
may call to items in a different order than other versions of Node.Fixes #2675