FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    PATCH method for client libraries

    Scheduled Pinned Locked Moved
    Q&A
    0
    4
    566
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cyrill.lippuner
      last edited by

      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 any update<Resource>() method and was therefore wondering why no .withMethod("PATCH") for lets say updatePartial<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

      1 Reply Last reply Reply Quote 0
      • joshuaJ
        joshua
        last edited by

        @cyrill-lippuner

        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

        1 Reply Last reply Reply Quote 0
        • C
          cyrill.lippuner
          last edited by cyrill.lippuner

          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 the PUT request, I am forced to GET the object first to then be able to change information and send a second PUT request to update it. BUT, when I have the object-id already, I can directly PATCH 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.)

          1 Reply Last reply Reply Quote 0
          • joshuaJ
            joshua
            last edited by

            @cyrill-lippuner

            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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post