This is "soft" aletrnative of paramsFromClient hook.
When you use paramsFromClient
in app.hook.ts
, it fully removes $client
property (which contains all params), so we loose possibility to use params in service's hooks.
globalParamsFromClient
solve this problem.
await this.$store.dispatch('your-service/find',
paramsForServer({
query: { type: 'custom' },
schema: 'alt-1'
})
)
On server params will look like this:
{
query: { type: 'custom' },
$client: { schema: 'alt-1' }
}
export default {
before: {
...
find: [
paramsFromClient('disableParanoid')
],
...
}
}
It whitelist only "disableParanoid" param and remove all others ($client
removed).
export default {
before: {
...
find: [
paramsFromClient('schema')
],
...
}
}
No effect, we will never get schema param, if use paramsFromClient in app.hook.ts.
export default {
before: {
...
find: [
globalParamsFromClient('disableParanoid')
],
...
}
}
It whitelist "disableParanoid" param, remove it from $client and pass all others to your paramsFromClient
handlers.
export default {
before: {
...
find: [
paramsFromClient('schema')
],
...
}
}
So here you will get schema param!