Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/react/src/data-connect/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@ export type FlattenedMutationResult<Data, Variables> = Omit<
"data" | "toJSON"
> &
Data;

export enum CallerSdkType {
Base, // Core JS SDK
Generated, // Generated JS SDK
TanstackReactCore, // Tanstack non-generated React SDK
GeneratedReact, // Generated React SDK
TanstackAngularCore, // Tanstack non-generated Angular SDK
GeneratedAngular // Generated Angular SDK
}
9 changes: 6 additions & 3 deletions packages/react/src/data-connect/useDataConnectMutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
type QueryRef,
executeMutation,
} from "firebase/data-connect";
import type { FlattenedMutationResult } from "./types";
import { CallerSdkType, type FlattenedMutationResult } from "./types";

export type useDataConnectMutationOptions<
TData = unknown,
Expand Down Expand Up @@ -48,10 +48,10 @@
FlattenedMutationResult<Data, Variables>,
FirebaseError,
Variables
>
>,
_callerSdkType: CallerSdkType = CallerSdkType.TanstackReactCore
) {
const queryClient = useQueryClient();

return useMutation<
FlattenedMutationResult<Data, Variables>,
FirebaseError,
Expand All @@ -78,6 +78,9 @@
},
mutationFn: async (variables) => {
const mutationRef = typeof ref === "function" ? ref(variables) : ref;

// @ts-expect-error function is hidden under `DataConnect`.
mutationRef.dataConnect._setCallerSdkType(_callerSdkType);

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes create mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:80:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes update mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:111:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes delete mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:163:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent create mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:228:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:226:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent upsert mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:280:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:278:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent delete mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:357:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:355:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:418:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:460:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with both variable and non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:503:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for upsert mutations with non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:545:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes create mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:80:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes update mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:111:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > executes delete mutation successfully thus returning flattened data including ref, source, and fetchTime

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:163:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent create mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:228:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:226:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent upsert mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:280:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:278:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > handles concurrent delete mutations

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:357:24 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:355:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:418:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:460:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for create mutations with both variable and non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:503:7

Check failure on line 83 in packages/react/src/data-connect/useDataConnectMutation.ts

View workflow job for this annotation

GitHub Actions / test

packages/react/src/data-connect/useDataConnectMutation.test.tsx > useDataConnectMutation > invalidates queries specified in the invalidate option for upsert mutations with non-variable refs

TypeError: mutationRef.dataConnect._setCallerSdkType is not a function ❯ Object.mutationFn packages/react/src/data-connect/useDataConnectMutation.ts:83:31 ❯ Object.fn node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:170:29 ❯ run node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:157:49 ❯ Object.start node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/retryer.ts:222:9 ❯ Mutation.execute node_modules/.pnpm/@TanStack[email protected]/node_modules/@tanstack/query-core/src/mutation.ts:208:40 ❯ packages/react/src/data-connect/useDataConnectMutation.test.tsx:545:7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of calling _setCallerSdkType() here, we're planning to pass the _callerSdkType as an argument to the ref function, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think calling _setCallerSdkType on the Data Connect object would be preferred because the mutation hook accepts a ref function OR a ref that has already been created.

const response = await executeMutation<Data, Variables>(mutationRef);

return {
Expand Down
7 changes: 5 additions & 2 deletions packages/react/src/data-connect/useDataConnectQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
executeQuery,
} from "firebase/data-connect";
import type { PartialBy } from "../../utils";
import type { FlattenedQueryResult } from "./types";
import { CallerSdkType, type FlattenedQueryResult } from "./types";


export type useDataConnectQueryOptions<
TData = unknown,
Expand All @@ -19,6 +20,7 @@ export function useDataConnectQuery<Data = unknown, Variables = unknown>(
FlattenedQueryResult<Data, Variables>,
FirebaseError
>,
_callerSdkType: CallerSdkType = CallerSdkType.TanstackReactCore
) {
let queryRef: QueryRef<Data, Variables>;
let initialData: FlattenedQueryResult<Data, Variables> | undefined;
Expand All @@ -34,7 +36,8 @@ export function useDataConnectQuery<Data = unknown, Variables = unknown>(
} else {
queryRef = refOrResult;
}

// @ts-expect-error function is hidden under `DataConnect`.
queryRef.dataConnect._setCallerSdkType(_callerSdkType);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of calling _setCallerSdkType() here, we're planning to pass the _callerSdkType as an argument to the ref function, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

return useQuery<FlattenedQueryResult<Data, Variables>, FirebaseError>({
...options,
initialData,
Expand Down