Skip to content

How to cancel/abort a mutation query? #1551

Answered by TkDodo
Merott asked this question in Q&A

You must be logged in to vote

I don't think there is. The thing is: queries have no side-effect on the server, so you can run them as often as you want and also cancel them if you are no longer interested in the result. Per default, react-query will only ignore the result, but you can also attach a cancel method to the Promise to really abort the network request.

But as soon as you've fired off a mutation, once the backend has received it and has potentially started to update a database entry - how would you cancel that from the frontend... 🤷 .

Can you maybe elaborate on your use-case - what do you want to achieve?

Replies: 21 comments 37 replies

You must be logged in to vote
3 replies
@Merott

@nikhilyadav-innostax

@chihabhajji

Answer selected by Merott

You must be logged in to vote
5 replies
@TkDodo

@kripod

@kripod

@TkDodo

@kripod

You must be logged in to vote
2 replies
@p6l-richard

@lynxtaa

You must be logged in to vote
0 replies

You must be logged in to vote
4 replies
@TkDodo

@f0rr0

@TkDodo

@f0rr0

You must be logged in to vote
9 replies
@nathanhannig

@jcready

@TkDodo

@jcready

@TkDodo

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
2 replies
@TkDodo

@Estevete

You must be logged in to vote
0 replies

You must be logged in to vote
1 reply
@TkDodo

You must be logged in to vote
2 replies
@budroco

@TkDodo

You must be logged in to vote
0 replies

You must be logged in to vote
3 replies
@TkDodo

@benjamintd

@James-Whitfield

You must be logged in to vote
0 replies

You must be logged in to vote
3 replies
@TkDodo

@derekbking

@TkDodo

You must be logged in to vote
0 replies

You must be logged in to vote
3 replies
@TkDodo

@zedrdave

@TkDodo

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet