Skip to content

Pass Params to all service calls. #175

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

Merged
merged 4 commits into from
May 16, 2022

Conversation

dallinbjohnson
Copy link
Collaborator

Summary

I am wanting to pass all params except provider, and query to all service calls for auth management. This is so the internal call will get all params and custom params for server-side hooks. We need to pass additional params, but the current code is fixed.

@fratzinger
Copy link
Collaborator

Great addition!

Other libraries use a simple passParams/makeParams/params function (see feathers-fletching).

I would love to see this in f-a-m. A passParams option for the f-a-m service (these options).

To not introduce a breaking change it would be undefined per default. Most basic example would look like this:

(defaultParams, context) => defaultParams

Your approach would look like this:

(params) => {
  let {provider: _, query: __, ...passedParams} = params;
  return passedParams;
}

The advantage would be, that everyone can stretch it to his/her need, even context-based in a function. Maybe it's dependent on a user or permissions or...

@dallinbjohnson what do you think about this?

@fratzinger
Copy link
Collaborator

Thanks for the changes and nice that you added a test for it.

Could you please make passParams: undefined by default? That wouldn't mean a breaking change.

let passedParams = options.passParams && await options.passParams(params);

@dallinbjohnson
Copy link
Collaborator Author

@fratzinger Is there anything else I need to do to get this approved to be merged?

@fratzinger
Copy link
Collaborator

Sorry for the delay. If @claustres gives his okay, I'm happy to merge :)

@claustres
Copy link
Collaborator

I am not really able to follow all changes on the current projects I am involved into so do not hesitate to go ahead, no breaking changes, some tests 👍

@fratzinger fratzinger merged commit add37e6 into feathersjs-ecosystem:master May 16, 2022
@fratzinger
Copy link
Collaborator

released as v3.2.0. Thanks @dallinbjohnson for the PR and the quick adjustments! Sorry again for the delay.
Thanks @claustres for the confidence 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants