invalidating the first key doesn't work
in tanstack query, what are the possible reason why invalidating
["user"]["user"] doesn't invalidate ["user", "some-username", "posts"]["user", "some-username", "posts"]? i'm sure that i'm using correctqueryClientqueryClientas well// useQuery
const threadsQuery = useInfiniteQuery(userThreadsInfiniteOptions(username));// useQuery
const threadsQuery = useInfiniteQuery(userThreadsInfiniteOptions(username));// options
export const userOptions = queryOptions({
queryKey: ["user"],
});
export const userThreadsInfiniteOptions = (username: string) => {
return infiniteQueryOptions({
queryKey: [userOptions.queryKey, username, threadInfiniteOptions.queryKey],
initialPageParam: undefined,
queryFn: async ({ pageParam }: { pageParam: string | undefined }) =>
getUserThreads({
username,
lastId: pageParam,
}),
getNextPageParam: (posts) => {
if (posts.length === 0) return undefined;
return posts[posts.length - 1].id;
},
});
};// options
export const userOptions = queryOptions({
queryKey: ["user"],
});
export const userThreadsInfiniteOptions = (username: string) => {
return infiniteQueryOptions({
queryKey: [userOptions.queryKey, username, threadInfiniteOptions.queryKey],
initialPageParam: undefined,
queryFn: async ({ pageParam }: { pageParam: string | undefined }) =>
getUserThreads({
username,
lastId: pageParam,
}),
getNextPageParam: (posts) => {
if (posts.length === 0) return undefined;
return posts[posts.length - 1].id;
},
});
};// invalidation
queryClient.invalidateQueries({
queryKey: userOptions.queryKey,
});// invalidation
queryClient.invalidateQueries({
queryKey: userOptions.queryKey,
});