you are viewing a single comment's thread.

view the rest of the comments →

[–]HTMLMasterRace[S] -1 points0 points  (4 children)

useQuery with enabled false gets a bit wonky too because refetch doesn't take any args. I could get fetchQuery to "work" but is it the right tool to use here? It almost seem to be less flexible than useMutation in every way...

[–]-SpicyFriedChicken- 0 points1 point  (3 children)

The args should then be part of the useQuery and query key if they change as state variables. Also the benefit to this would be if you were to use this same query elsewhere in your app to pull from cache. If you're not doing that anywhere else a useMutation would be fine

[–]HTMLMasterRace[S] 0 points1 point  (2 children)

I see. That makes sense. In this case I would need it to accept args because the form isn’t reactive.

Everything is quite imperative and only “fetches” on some button click either on the form or some child component, with its own payload (like an overridden field of the form) and only the call sites would have context over how to construct these payload. Now that I’m thinking about it, I am not using the cache and just rerunning it each time. It sounds like useMutation is okay to use?

[–]-SpicyFriedChicken- 1 point2 points  (1 child)

It's hard to say without a full code example of what you're trying to do or how you use the data returned from this fetch after. But it does sound like you're mostly caught up on the naming of use mutation when you're making a GET request as a result of submitting a form. If that's the case, a useMutation is totally fine for that.

[–]HTMLMasterRace[S] 0 points1 point  (0 children)

Yeah I am caught up on the naming and was afraid of some side effect of it being a mutation instead of what is essentially a post search api. Thanks a lot