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

Params not passed to server #150

Open
EmileSpecs opened this issue Oct 12, 2023 · 2 comments
Open

Params not passed to server #150

EmileSpecs opened this issue Oct 12, 2023 · 2 comments

Comments

@EmileSpecs
Copy link

EmileSpecs commented Oct 12, 2023

Hi

Perhaps I'm missing something, why is the params not passed to the server here?

const { api } = useFeathers()
const service = api.service('users')
const state = service.new()

state.save({
    $clientData: {
      verifyUrl: `${url.protocol}//${url.host}/auth/status/verified`
    }
  })

The query params is received empty on the server.
I've added $clientData to paramsForServer list in createPiniaClient config.

Even though params is listed for all instance methods, in the Pinia client config is says:
"paramsForServer is an array of query keys for findInStore to ignore and pass to the find action's query."

So does params only get sent to server for find?

If so, is there no other way to send params for other types of requests?

@EmileSpecs
Copy link
Author

I've tested this quite thoroughly now and it seems like for instance.create no params are passed to server, it's also not present in feathersClient before hooks.

For instance.patch however, the params are set in before hooks.

The paramsForServer still doesn't seem to do anything though?

My expectation is that it is added to params.query.$client (for example) and then I use the paramsFromClient hook on the server to add it back into ctx.params and remove it from the query.

I've now done that manually in all before hooks:

before: {
      all: [
        (ctx: any) => {
          const { query, ...params } = ctx.params
          
            // add the $client key to the query
            if (Object.keys(params).length > 0) {
              ctx.params.query = {
                $client: params,
                ...query,
              }
            }
}
]}

So this workaround works well for anything besides instance.create as no params are passed to the Feathers client.
Is this expected behaviour, as the docs specify that a params param is accepted for instance.create.

@marshallswain
Copy link
Owner

Every Feathers interface accepts params, but params aren't passed by default. I'm not sure that I've ever used custom params on create. It makes more sense to me to use the data interface for create, now... but it seems like I did have params working for create back in the feathers-vuex days. I'm not sure when I'll be able to address this. I'm merging in all PRs that are ready, today. If you want to create a PR, I'll review it in the next batch, which would be a couple of weeks away, likely. If not, please work around the issue by using data.

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

2 participants