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

Separate "query" from other parameters in service calls #557

Open
hubgit opened this issue Apr 20, 2017 · 6 comments
Open

Separate "query" from other parameters in service calls #557

hubgit opened this issue Apr 20, 2017 · 6 comments

Comments

@hubgit
Copy link

hubgit commented Apr 20, 2017

It's common to pass a query to the find service method, but less common to pass any other parameters, so for convenience perhaps query should be separated from params in service calls.

class MyService {
  find(params) {}
  get(id, params) {}
  create(data, params) {}
  update(id, data, params) {}
  patch(id, data, params) {}
  remove(id, params) {}
  setup(app, path) {}
}

would become

class MyService {
  find(query, params) {}
  get(id, params) {}
  create(data, params) {}
  update(id/query, data, params) {}
  patch(id/query, data, params) {}
  remove(id/query, params) {}
  setup(app, path) {}
}

This is obviously a breaking change, but now seems as good a time as any to consider implementing it (or not).

Previous discussion:

@marshallswain
Copy link
Member

Same for get.

get(id/query, params) {}

I like this idea, but @daffl will have thought this through more than I.

@daffl
Copy link
Member

daffl commented Apr 20, 2017

Yeah, @ekryski has been a big proponent of this change, too. The only tricky part would be backwards compatibility with old services. I am not sure there is a way to feature detect this at all (maybe with the method arity of find via service.find.length but it won't work if someone is still using callbacks - which we really should throw a warning or an error by now).

It would definitely help clear up the confusion about which parameters are passed between the server and the client (and mistakes of doing a .find all accidentally).

@ekryski
Copy link
Contributor

ekryski commented Apr 25, 2017

I was literally just thinking about this today. This has come up a lot and I've also been burned a few times by the existing query syntax.

I'm going to create an issue for a proposal as this definitely would be MASSIVE breaking change and effects just about everything. However...

I think we could create a hook that you can include that would be able to map a new hook format back to the legacy one and we'd be able to roll out new major versions of adapters.

The next release would be the time to do it as we are planning on bringing feathers-hooks into core feathers itself.

@eddyystop
Copy link
Contributor

I have doubts if this mainly visual change is worth the problems its going to cause.

@idibidiart
Copy link

I think 'params' is overloaded.

It contains 'provider' and 'token' which should be split up under a 'context' argument

It also contains 'query' in case of find()

It also contains an array of ids in case of patch() and remove() ... not sure about update() ... I don't even recall how to supply the ids in params but maybe id: [...ids] ?

I think we should split into query, context and id array.

Noob comment. Just getting back to Feathers.

@idibidiart
Copy link

Or id argument can be string or array

so:

id (string or array)
query (object)
context (object)

params as it is is too overrloaded and hard to remember the details

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

6 participants