-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
// api configuration
invalidationBehavior: "delayed"
// queries
getQuery: build.query<>({
query:...,
providesTags: ["QueryTag"]
}),
editQuery: build.mutation<>({
invalidatesTags: ["QueryTag"]
}),
getSomeUnrelatedListData: buld.query<>({
query:...
async onQueryStarted(_, { dispatch, queryFulfilled }) {
try {
const res = await queryFulfilled;
const results = res.data;
dispatch(
apiI.util.upsertQueryEntries(
results.map((result) => ({
endpointName: "getSomeUnrelatedSingleItemData",
arg: { id: result.id },
value: result,
})),
),
);
} catch (err) {
void err;
}
},
}),
}),
getSomeUnrelatedSingleItemData: buld.query<unknown, {id: number}>({
})
Steps:
- Trigger fetching the data by calling the getQuery (useGetQueryQuery())
- Trigger fetching the data by calling the getSomeUnrelatedListData (useGetSomeUnrelatedListDataQuery())
- this populates entries for getSomeUnrelatedSingleItemData
- Trigger getQuery data invalidation by calling the editQuery mutation
Expected result:
data returned by the useGetQueryQuery() is re-fetched
Actual Result:
the data is not re-fetched
"@reduxjs/toolkit": "2.4.0",