mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-20 12:30:04 +00:00
git-subtree-dir: packages/browseros-agent git-subtree-mainline:8f148d0918git-subtree-split:90bd4be300
24 lines
685 B
TypeScript
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 ?? {}),
|
|
})
|
|
}
|