-
-
Notifications
You must be signed in to change notification settings - Fork 751
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
fix(client): Add underscored methods to clients #3176
fix(client): Add underscored methods to clients #3176
Conversation
This makes sense. The tests should pass when rebasing with latest. |
@daffl Should I update this line to throw an error for feathers/packages/rest-client/src/base.ts Line 142 in 4676d04
I am thinking something like if (typeof id === 'undefined' || id === null) {
return Promise.reject(new Error("id for 'update' can not be undefined or null"))
} |
The id for update can be I also forgot to mention that we should probably do this for the Socket.io client as well. |
All updated @daffl. Let me know if you need anything else. |
Great, thank you! Will go out with the next release. |
This PR adds the common
_get
,_find
,_create
,_update
,_patch
, and_remove
methods to both the Rest and Socket client services. These methods are common for all Feathers database adapters (and many other feathers libraries) and offer a convenient way to call service methods without hooks. But, this convention has never been available to the default client services. These methods will be helpful on the client in retries, caching, batching and any number of other reasons a user may want to call the underlying http/socket request without running client hooks.This PR also follows this convention for the user's custom methods. Note that it does not attempt to call a server's version of this underscored method (if it even existed). It is only a convention on the client side that would allow the client to call the underscored method without running client hooks, even if they did not implement this convention on the server.
I am terrible at TS. This was a very easy update to make to both the code and the types. But I am not sure if I would need to handle types anywhere else? All of the tests are passing.
I also updated the
body
var name todata
in the REST service. It felt weird and inconsistent that it was calledbody
in those methods. And I updated the RESTupdate
method to useId
instead ofNullableId
. And I updated the Socket service to useD
for data instead ofany
. Like I said, I am not great at TS and hope this doesn't break anything, but it felt like a nice consolidation and cleanup.