Hi, I just tried useLazyQuery for triggering query imperatively, and I found that the "execute function" would not resolve query result, but resolve with undefined.
This behavior make developer can't get query result by await the execute function.
For example, if I want to imperatively trigger query in a handleClick function and instantly use this result to do some calculating or logic, we can't.
In addition, since useMutation has a similar returning API with useLazyQuery and Mutate function will resolve fetch result, and same on refetch function of useQuery. I think useLazyQuery should has similar behavior. It should resolve with fetch result.


Thanks!
Yes please 馃 Having to store the result in component state is a pita.
Totally agree with this.
useMutation API is predictable enough.
useLazyQuery has a very similar use case (speaking of imperative execution), and should have the same output type.
@tz5514 have you resolved this issue?
@srijanrana no, still use refetch of useQuery to replace it now.
refetch on useQuery is only helpful if you want to display the new data. It is not helpful if you want to not call the query on page load, but you want to call it on a user method and do something with it immediately.
Most helpful comment
refetchonuseQueryis only helpful if you want to display the new data. It is not helpful if you want to not call the query on page load, but you want to call it on a user method and do something with it immediately.