-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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(query-core): improve type safety and performance in getMutationDefaults
#8669
base: main
Are you sure you want to change the base?
refactor(query-core): improve type safety and performance in getMutationDefaults
#8669
Conversation
…tionDefaults` - Change return type to exclude mutationKey using OmitKeyof - Replace spread operator with Object.assign for better performance
View your CI Pipeline Execution ↗ for commit af7aa1e.
☁️ Nx Cloud last updated this comment at |
result = { ...result, ...queryDefault.defaultOptions } | ||
Object.assign(result, queryDefault.defaultOptions) |
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.
Aligning implementation with getQueryDefaults by using Object.assign
@Nick-Lucas do you remember why you changed this to Object.assign
in getQueryDefaults
?
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.
Yes, it's potentially a faster operation and in some cases looks cleaner. That's it. But the difference in speed is probably virtually irrelevant as both approaches are very fast
https://www.measurethat.net/Benchmarks/Show/2485/0/spread-vs-objectassign#:~:text=Executions%20per%20second-,Object.assign%20two%20objects,226555.7%20Ops/sec,-Object.assign%20three (note: the "AI summary" on this page doesn't understand the results and is confidently hallucinating the opposite results of what the data shows which is funny but confusing)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8669 +/- ##
===========================================
+ Coverage 46.31% 63.11% +16.79%
===========================================
Files 199 135 -64
Lines 7552 4855 -2697
Branches 1731 1368 -363
===========================================
- Hits 3498 3064 -434
+ Misses 3674 1546 -2128
+ Partials 380 245 -135 |
Description
Improve type safety and performance in
getMutationDefaults
by:OmitKeyof<MutationObserverOptions<any, any, any, any>, 'mutationKey'>
to ensure the return type matches the type defined insetMutationDefaults
getQueryDefaults
by usingObject.assign