Skip to content
Discussion options

You must be logged in to vote

When sending query, mutation requests, I expected that adding onError to options would be an override, but it was not.

onError added to useQuery will overwrite the one passed to defaultOptions. However, those error handlers will be executed for every observer (=useQuery instance).

So I would stick to the global handler on the queryCache / mutationCache. Those handlers do get the whole query / mutation passed as the second parameter, so you can decide to not handle something for a specific key. Also, you can use the meta field on query/mutation to "tag" it in some way. This field is also available. For example, you could only show errors for queries that have a message passed:

const quer…

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@hoo00nn
Comment options

@palmmymumu
Comment options

@TkDodo
Comment options

@goacgras
Comment options

@TkDodo
Comment options

Answer selected by hoo00nn
Comment options

You must be logged in to vote
1 reply
@TkDodo
Comment options

Comment options

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
6 participants