merge params deeply & ability to pass a function #16
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.
This PR addresses the params property, which was pretty useless. Basically there were 3 problems:
Object.assign
for params shallow merges the query so the query becomes overwritten -> only params without thequery
-property make sense.query
?The 1. point is also mentioned in #15. Marshall came up with the idea of an function to manipulate the params after feathers-shallow-populate. I achieved the solution with two approaches:
lodash/merge
for the passedparams
object to merge deeply.params: (params) => {}
. The function can manipulate the passedparams
or return a newparams
object which gets merged deeply.For the 3. point it made sense for me to also pass the context down to the
params
object:params: (params, context) => {}
. This way thecontext.params.authentication
can be passed toparams.authentication
orcontext.params.user
toparams.user
This feature is totally optional. I wrote tests for the various approaches. The deep merge instead of the shallow
Object.assign
changes the behaviour, I guess, but makes it better.I also documented the possible values in the README.md. This can also be copied to feathers-graph-populate which addresses marshallswain/feathers-graph-populate#12