Skip to content

Commit

Permalink
fix: Allow queryKey to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehesp committed Dec 16, 2024
1 parent aef9440 commit a33dcf7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/react/src/data-connect/useConnectQuery.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { useQuery, type UseQueryOptions } from "@tanstack/react-query";
import { type FirebaseError } from "firebase/app";
import type { PartialBy } from "../../utils";
import {
type QueryRef,
type QueryResult,
executeQuery,
} from "firebase/data-connect";

type UseConnectQueryOptions<TData = unknown, TError = FirebaseError> = Omit<
UseQueryOptions<TData, TError>,
"queryFn"
>;
type UseConnectQueryOptions<
TData = unknown,
TError = FirebaseError
> = PartialBy<Omit<UseQueryOptions<TData, TError>, "queryFn">, "queryKey">;

export function useConnectQuery<
Data extends Record<string, any>,
Expand Down
3 changes: 3 additions & 0 deletions packages/react/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ const wrapper = ({ children }: { children: ReactNode }) => (
);

export { wrapper, queryClient };

// Helper type to make some properties of a type optional.
export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

0 comments on commit a33dcf7

Please sign in to comment.