Invalidation from Mutations #506
Replies: 4 comments
-
Hello @reichhartd, with the new orval@alpha you can now pass a |
Beta Was this translation helpful? Give feedback.
-
@reichhartd Did you eventually solve this using the queryOptions or mutationOptions? And if so, do you happen to have a snippet to share? I’m in the same boat and have been looking for a way to invalidate queries on a POST |
Beta Was this translation helpful? Give feedback.
-
Hey @anymaniax @daviesro |
Beta Was this translation helpful? Give feedback.
-
@anymaniax Do you have an example of how the new |
Beta Was this translation helpful? Give feedback.
-
Currently, we invalidate queries based on mutations according to the instructions on the React Query website.
We would like to keep it that way. To implement this with the automatic API generation I see two possibilities:
MutationObserver
React Query gives you the possibility to observe mutations. As far as I understand, this is only properly possible if you provide a
mutationKey
. Orval does not use amutationKey
for mutations at the moment.Override
You use the
override
as follows:However, there are several problems with this:
You can give
options
only forqueries
, nomutations
.Asynchronous functions are not generated correctly
Certain imports like
queryClient
orgetFindUsersQueryKey
are missing. I can import them viaheader
, but not for specific files. We use themode
tags-split
, and therefore thisheader
is used in every file, even if it is not necessary there. This generates TypeScript errors.@anymaniax Did I miss a possibility? What would be your advice on which way I should go?
Beta Was this translation helpful? Give feedback.
All reactions