Shaddix / react-query-swagger

Generates react-query hooks based on Swagger API definitions
MIT License
122 stars 4 forks source link

useMutation without id #22

Closed panda7789 closed 1 year ago

panda7789 commented 1 year ago

Hi, I have question about mutations.

I have this backend controller: image React-query-swagger generates this: image

And now, because I have ID in url, it is needed while initializing useUsersPUTMutation. So I cannot use useMutation for multiple users. Or sometimes I dont know ID on initialization. So I'm doing workaround and using Client.usersPUT(id, body) directly when I know ID.

But I'm wondering if it is good practice to using usersPUT directly, and if I'm not loosing any of features that useUsersPUTMutation adds.

Thank you in advance for your time :)

Shaddix commented 1 year ago

Personally I'm not using mutations that often. I mean, I almost never send GET requests directly (always work with useQuery), but for POST/PUT/DELETE requests, in over 60% of the cases I send them via Client methods just as you shown.

So for me it feels ok (at least I'm doing the same thing) :)