/** * Branch heads — mutable pointers into the commit chain * @generated by @constructive-io/graphql-codegen * DO NOT EDIT - changes will be overwritten */ import { useMutation, useQueryClient } from '@tanstack/react-query'; import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query'; import { getClient } from '../client'; import { buildSelectionArgs } from '../selection'; import type { SelectionConfig } from '../selection'; import { databaseGraphRefKeys } from '../query-keys'; import { databaseGraphRefMutationKeys } from '../mutation-keys'; import type { DatabaseGraphRefSelect, DatabaseGraphRefWithRelations, CreateDatabaseGraphRefInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { DatabaseGraphRefSelect, DatabaseGraphRefWithRelations, CreateDatabaseGraphRefInput, } from '../../orm/input-types'; /** * Branch heads — mutable pointers into the commit chain * * @example * ```tsx * const { mutate, isPending } = useCreateDatabaseGraphRefMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateDatabaseGraphRefMutation( params: { selection: { fields: S & DatabaseGraphRefSelect; } & HookStrictSelect, DatabaseGraphRefSelect>; } & Omit< UseMutationOptions< { createDatabaseGraphRef: { databaseGraphRef: InferSelectResult; }; }, Error, CreateDatabaseGraphRefInput['databaseGraphRef'] >, 'mutationFn' > ): UseMutationResult< { createDatabaseGraphRef: { databaseGraphRef: InferSelectResult; }; }, Error, CreateDatabaseGraphRefInput['databaseGraphRef'] >; export function useCreateDatabaseGraphRefMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: databaseGraphRefMutationKeys.create(), mutationFn: (data: CreateDatabaseGraphRefInput['databaseGraphRef']) => getClient() .databaseGraphRef.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: databaseGraphRefKeys.lists(), }); }, ...mutationOptions, }); }