PATCH method for client libraries
-
Hello,
I am using the typescript client library and I was wondering whether the PATCH method is also available somewhere in there, which is documented in the REST API though.
The PUT request, as usually used by
update<Resource>()
overwrites the complete object and requires to retrieve the object beforehand. The PATCH would allow to just overwrite some values and is very handy. (Currently I use it for example to setup my default tenant while kickstarting)I have seen in the library that there is a function
.withMethod("PUT")
here which gets called from anyupdate<Resource>()
method and was therefore wondering why no.withMethod("PATCH")
for lets sayupdatePartial<Resource>()
? The client libs are autom. generated if I understood this correctly, so it should not be such a big problem, or did I miss something crucial?Thx for clarification!
Cyrill
-
Can you confirm what endpoint you would like to use the patch on?
This, of course, could be missing functionality within this library. If you could expand with a few details to confirm what you are attempting, that would be great.
Thanks,
Josh
FusionAuth -
Sure!
The
PUT
method is used to replace an existing object completely with the provided information. This means I need to provide the complete informations of the object even when I only want to update one single value. (If I don't, all values which already exist but I do not provide get wiped!)The
PATCH
method will merge the provided information into the existing object, meaning I can only give the missing information without having to provide the rest of the values, too.This is already implemented on the
API
level of fusionauth, but just not available in the client libraries. This would be very handy, as with thePUT
request, I am forced toGET
the object first to then be able to change information and send a secondPUT
request to update it. BUT, when I have the object-id already, I can directlyPATCH
a single data field and cut the transaction count in half.You can have a look at the different ways described here.
I hope this is clearer now, otherwise come back to me
PS: I would like to have this on every endpoint which already provides PATCH methods documented in the api docs here. (The functionality is already there, just not accessible by the client libs.)
-
Ah, ok the scope of the question/request makes sense to me.
With the disclaimer that I have not used the typescript library extensively (yet), when I search this library for "patch" it does appear that we do support PATCH.
Can you confirm that you see this as well (or possibly I am overlooking something)
https://github.com/FusionAuth/fusionauth-typescript-client/blob/master/src/FusionAuthClient.ts (this is the library I searched)
Thanks
Josh