Files
BrowserOS/packages/browseros-agent/apps/agent/lib/graphql/useGraphqlMutation.ts
Dani Akash 290ee91a8b Add 'packages/browseros-agent/' from commit '90bd4be3008285bf3825aad3702aff98f872671a'
git-subtree-dir: packages/browseros-agent
git-subtree-mainline: 8f148d0918
git-subtree-split: 90bd4be300
2026-03-13 21:22:09 +05:30

24 lines
685 B
TypeScript

import {
type UseMutationOptions,
type UseMutationResult,
useMutation,
} from '@tanstack/react-query'
import type { TypedDocumentString } from '@/generated/graphql/graphql'
import { execute } from './execute'
/**
* @public
*/
export function useGraphqlMutation<TResult = unknown, TVariables = object>(
document: TypedDocumentString<TResult, TVariables>,
options?: Omit<
UseMutationOptions<TResult, unknown, TVariables>,
'mutationFn' | 'mutationKey'
>,
): UseMutationResult<TResult, unknown, TVariables> {
return useMutation<TResult, unknown, TVariables>({
mutationFn: (variables: TVariables) => execute(document, variables),
...(options ?? {}),
})
}