Skip to content
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

paramsForServer Hook #670

Open
DaddyWarbucks opened this issue Jun 2, 2022 · 2 comments
Open

paramsForServer Hook #670

DaddyWarbucks opened this issue Jun 2, 2022 · 2 comments

Comments

@DaddyWarbucks
Copy link
Contributor

DaddyWarbucks commented Jun 2, 2022

I think we should update the docs to include an example of how one might use the paramsForServer as a hook.

const paramsForServerHook = (...whitelist) => (context) => {
  context.params = paramsForServer(context.params, ...whitelist);
  return context;
};

I am not a fan of having to use the paramsForServer on every service call and would rather have it work more generically via a client side hook.

I can update the docs at some point, but wanted to capture my solution.

@fratzinger
Copy link
Collaborator

I would go a more drastic way. We should deprecate the current paramsForServer util and add a paramsForServerHook and advertise it as the new way to go.

In a next major release, I would like to rename the paramsForServer util to paramsForServerUtil.
And in another major release I would like to rename paramsForServerHook to paramsForServer.

@daffl
Copy link
Member

daffl commented Feb 16, 2023

Here is a question, what do the params hooks do differently than something like this?

async (context) => {
  const { myParam, ...query } = context.params.query || {}

  context.params = {
    ...query,
    myParam
  }
}

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

No branches or pull requests

3 participants