setDefaultOptions -> refetchQueries race condition?
I'm trying to set a global
I came up with this:
My queryFn looks like this:
So the result is that after the first refetchQueries, my queryFn gets called with
I also tried it with invalidateQueries (which I looked at the code that it eventually calls refetchQueries and is also awaitable), but the behavior is the same.
Am I missing something? I did not expect it to be delayed like this. I could always use
meta option that my queryFns will recognize and do a fetch(..., {cache: "reload"}) HTTP request.I came up with this:
My queryFn looks like this:
So the result is that after the first refetchQueries, my queryFn gets called with
meta === {} but the default options are observable and up to date already, with meta.reload == true. Only by the second refetchQueries are both meta and client.getDefaultOptions().queries.meta the same within queryFn.I also tried it with invalidateQueries (which I looked at the code that it eventually calls refetchQueries and is also awaitable), but the behavior is the same.
Am I missing something? I did not expect it to be delayed like this. I could always use
client.getDefaultOptions() in my queryFns but I'd rather figure out the root cause.