-
Notifications
You must be signed in to change notification settings - Fork 89
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
stashBefore - Invalid query parameter $disableStashBefore #511
Comments
Its failing in the FeathersJS hook handler either on the |
We also have the same issue and have found a workaround. The reason is that the stashBefore hook is setting a $disableStashBefore property in the The outcome of the error is that To prove my point, the simple solution is to use another hook from this package, Example config:
Regarding the reasons of putting Of course this workaround may have another implications, perhaps @eddyystop you can explain the reasoning or the need of that query parameter to let people know of possible side-effects. |
Any of the populate hooks will cause another service to read records. We
don't want those other services to also try to stash records if they too
use the stashRecird hook. The $disableStash flag is set by the root service
to prevent this.
It may look hacky but it's traditional Feathers.
…On Thu., May 30, 2019, 06:38 Carlos de la Orden, ***@***.***> wrote:
We also have the same issue and have found a workaround.
The reason is that the stashBefore hook is setting a $disableStashBefore
property in the params.query object (for reasons I've yet to understand as
it feels like a hack, when you have the full context to share info
between hooks). Now that is not valid query parameter to send to mongoose,
for example.
The outcome of the error is that context.params.before is undefined
because the get call fails, defeating the purpose of using stashBefore at
all. :)
To prove my point, the simple solution is to use another hook from this
package, discardQuery, and set it up before get` to discard that
parameter. Add it and the error disappears:
Example config:
before: { get: [discardQuery('$disableStashBefore')], patch:
[stashBefore(), yourHookThatNeedsStash, ...] }
Of course this workaround may have another implications, perhaps
@eddyystop <https://github.com/eddyystop> you can explain the reasoning
or the need of that query parameter to let people know of possible
side-effects.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#511>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAL3HH5LIEVGKAATVRLPH6TPX6VDRANCNFSM4G4XD44Q>
.
|
Sure, I'm sorry if it sounded rude on my part, not my intention at all. :) In that case perhaps the hook should check if something is already in I'm not too familiar with the hooks common code, but the status now is that, at least in some ORM adapters (knex from the original issue, mongoose in my case), using this |
I believe the simplest solution to this is to move the So we replace
with
|
I'm in agreement with @marshallswain. The proposed API looks like https://feathers-plus.github.io/v1/feathers-hooks-common/#paramsforserver ... and thus is not unusual. It also allows us to use stashBefore only on patch for instance. Which helps performance and readability. As a temporary fix, we should update the doc and mention that you MUST have stashBefore on the Here's how my patch2Update application hook looks because of this issue:
Here's how it COULD look with marshall's fix:
Are we taking PR's? |
Steps to reproduce
Add
stashBefore()
to the hooks of a simple service. The code looks like:Expected behavior
No errors.
Actual behavior
Not sure if this is an issue or misconfiguration.
The text was updated successfully, but these errors were encountered: