Skip to content

Commit f07c638

Browse files
committed
revert: query keys being passed into invalidate option
1 parent 8979820 commit f07c638

File tree

2 files changed

+2
-49
lines changed

2 files changed

+2
-49
lines changed

packages/react/src/data-connect/useDataConnectMutation.test.tsx

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -472,48 +472,6 @@ describe("useDataConnectMutation", () => {
472472
);
473473
});
474474

475-
test("invalidates queries specified in the invalidate option as a QueryKey", async () => {
476-
const movieData = {
477-
title: "tanstack query firebase",
478-
genre: "library",
479-
imageUrl: "https://invertase.io/",
480-
};
481-
482-
const createdMovie = await createMovie(movieData);
483-
484-
const movieId = createdMovie?.data?.movie_insert?.id;
485-
486-
const { result } = renderHook(
487-
() =>
488-
useDataConnectMutation(createMovieRef, {
489-
invalidate: [["GetMovieById", { id: movieId }]],
490-
}),
491-
{
492-
wrapper,
493-
}
494-
);
495-
const movie = {
496-
title: "TanStack Query Firebase",
497-
genre: "invalidate_option_test",
498-
imageUrl: "https://test-image-url.com/",
499-
};
500-
501-
await act(async () => {
502-
await result.current.mutateAsync(movie);
503-
});
504-
505-
await waitFor(() => {
506-
expect(result.current.status).toBe("success");
507-
});
508-
509-
expect(invalidateQueriesSpy.mock.calls).toHaveLength(1);
510-
expect(invalidateQueriesSpy).toHaveBeenCalledWith(
511-
expect.objectContaining({
512-
queryKey: ["GetMovieById", { id: movieId }],
513-
})
514-
);
515-
});
516-
517475
test("invalidates queries specified in the invalidate option for create mutations with both variable and non-variable refs", async () => {
518476
const movieData = {
519477
title: "tanstack query firebase",

packages/react/src/data-connect/useDataConnectMutation.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {
22
type UseMutationOptions,
3-
type QueryKey,
43
useMutation,
54
useQueryClient,
65
} from "@tanstack/react-query";
@@ -11,15 +10,15 @@ import {
1110
type QueryRef,
1211
executeMutation,
1312
} from "firebase/data-connect";
14-
import { isQueryKey, type FlattenedMutationResult } from "./types";
13+
import { type FlattenedMutationResult } from "./types";
1514

1615
export type useDataConnectMutationOptions<
1716
TData = unknown,
1817
TError = FirebaseError,
1918
Variables = unknown
2019
> = Omit<UseMutationOptions<TData, TError, Variables>, "mutationFn"> & {
2120
invalidate?: ReadonlyArray<
22-
QueryRef<unknown, unknown> | (() => QueryRef<unknown, unknown>) | QueryKey
21+
QueryRef<unknown, unknown> | (() => QueryRef<unknown, unknown>)
2322
>;
2423
};
2524

@@ -68,10 +67,6 @@ export function useDataConnectMutation<
6867
queryKey: [ref.name, ref.variables],
6968
exact: true,
7069
});
71-
} else if (isQueryKey(ref)) {
72-
queryClient.invalidateQueries({
73-
queryKey: ref,
74-
});
7570
} else {
7671
queryClient.invalidateQueries({
7772
queryKey: [ref.name],

0 commit comments

Comments
 (0)