-
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
Improving store write performance by avoiding unnecessary processing … #1675
Improving store write performance by avoiding unnecessary processing … #1675
Conversation
…of identical data when writing the store
@abergenw thanks a lot for this great PR! I definitely want to see this get merged, but it needs to test a bunch of corner cases before I'm confident enough to do so. Does this use
specifically, would address be the same in both cases and thus not get written with the extra Same question about aliases. Would be great to see tests for those (and other) cases. |
…nto data already written during the same write process
@helfer the whole point is avoiding writing the same object multiple times if it's occurring multiple times in the same graphql path (referential equality of field). There would be no short circuiting in the query you provided as the graphql paths are different. However, the following query/response would get short circuited:
I added a few test cases (and fixed a bug =)) but none covering aliased fields. Is this necessary, there is no special case for aliases in |
Should we try to detect when this is inconsistent and maybe throw an error? |
Not sure what you mean @stubailo. We deliberately want |
Yep! I'm just wondering if it's helpful to highlight errors in the case when it's not consistent, since that might mean for the developer that they have made a mistake. But that could be part of a different PR. |
If we check for inconsistency I don't think there's much performance improvements to be gained... |
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 added tests are great, just found a tiny typo. If comparison is ===
, then aliased nodes should not be identical, and thus the paths would be different. If that's the case, I'm happy to merge this without including specific tests for that.
test/writeToStore.ts
Outdated
}); | ||
}); | ||
|
||
it('preoprly normalizes an object occurring in the same graphql array path twice', () => { |
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.
"properly"
The strict equality check |
You could maybe put this behind a flag of |
@jbaxleyiii last I checked it was pretty close to ready, I just didn't have time to take another close look to make sure it's really good to merge. |
@abergenw Let's merge this! Thanks again for helping make Apollo faster! 🚀 |
…of identical data when writing the store.
As mentioned in #1409 there is some overprocessing occurring when writing to the store IF the same data is returned multiple times for the same graphql field. This PR allows short circuiting when running into an object that has already been processed.
TODO: