RTK 2.0 Migration: `upsertQueryEntries` does not allow `refetch` behavior
JacobJaffe opened this issue · 2 comments
Hi, I've been testing out migrating from upsertQueryData
to upsertQueryEntries
.
Before:
await Promise.all(
posts.map((post) =>
dispatch(
postsApi.util.upsertQueryData(
"getPost",
{
id: post._id,
},
post
)
)
)
);
After:
dispatch(
postsApi.util.upsertQueryEntries(
posts.map((post) => ({
endpointName: "getPost",
arg: {
id: post._id,
},
value: post,
}))
)
);
However, I've found that the refetching no longer works when initialized this way. I've verified that the tags get invalidated, but no new query gets fired off.
const { refetch } = useGetPost({ id: "foo" });
...
// does not work when the query is hydrated by `upsertQueryEntries`
refetch()
This is unexpected because this is a different behavior than the mapped-upsertQueryData behavior, and feels like a bug- I've connected a component via a useQuery
hook, so the subscription should be valid.
Yep, there was a similar report over in #4393 . Haven't had time to look into it yet.
I think you're referring to this comment?
FWIW, I'm not seeing any regressions when rolling back to upsertQueryData
(as mentioned in that comment), just this issue with upsertQueryEntries
.