-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Closed
Labels
Description
Describe the bug
At present, onSuccess() may return a promise that the library will await to finish processing a query/mutation result. However, that typing is restricted to a promise that explicitly returns void, rather than any which would be more appropriate.
To Reproduce
Fire an async mutation and in the onSuccess, return another async mutation that is meant to happen using the data from the first. TS issues a compiler error because mutateAsync does not resolve to Promise<void>.
Expected behavior
The accepted return type for onSuccess should be Promise<any> so you can do whatever you want to in the onSuccess handler.
Current mitigation
This can currently be worked around by recasting the onSuccess return:
mutateAsync1(payload, {
onSuccess(data) {
return (mutateAsync2(data.token) as unknown) as Promise<void>
}
})