-
Notifications
You must be signed in to change notification settings - Fork 4
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
fix: replace merge()
with Object.assign()
#24
Open
KATT
wants to merge
1
commit into
prisma-labs:main
Choose a base branch
from
KATT:katt/patch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 will do a shallow merge, we should actually add tests and docs about how merging works.
We definitely want a deep merge.
But maybe we do have something not desirable about the lodash algo. Can you investigate an isolated example of how the merge is not doing what you want/expect?
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.
What is the benefit of a deep merge? Will reference what I am doing as soon as the PR working in general. Will probably send it over tomorrow.
I want some of my values in my context mutable from within itself. But maybe there's an error with my code.
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.
It is pretty case dependent. Happy to look at your case though. Maybe we need a toggle to enable or disable deep merge e.g.:
Note that this has an impact on the static types. The static types currently do a deep merge. The only way to to get the static typing change from this runtime setting change would be either some pretty complex typegen stuff or, more simply, via keeping the settings change in the chain. Reuse can be achieved like so:
Now all code needs to import and use
mykonn
instead ofkonn
.Providers API doesn't need to worry about this I think.
Making static types not do a deep merge will take some additional effort in this PR.
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 would expect it to simply blow up if the keys collide as there's no good way of approaching it - both merging and overriding have drawbacks - I'd treat it as an implementation error.
In tRPC I have a bunch of similar cases and the way I deal with it is that I make the server explode on bootup if you accidentally achieve "impossible" states (duplicate queries/multiple data transformers/[..]).
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.
@KATT Strict mode sounds nice, I see a union instead of boolean then:
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.
If you don't actually utilize the behavior of being able to deep merge props in any of your apps already, I think you should just delete it. Always great to opt for keeping the API surface area slim & keeping deps to a minimum when making libs.