/** * Create mutation hook for TransferLogModule * @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 { transferLogModuleKeys } from '../query-keys'; import { transferLogModuleMutationKeys } from '../mutation-keys'; import type { TransferLogModuleSelect, TransferLogModuleWithRelations, CreateTransferLogModuleInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { TransferLogModuleSelect, TransferLogModuleWithRelations, CreateTransferLogModuleInput, } from '../../orm/input-types'; /** * Mutation hook for creating a TransferLogModule * * @example * ```tsx * const { mutate, isPending } = useCreateTransferLogModuleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateTransferLogModuleMutation( params: { selection: { fields: S & TransferLogModuleSelect; } & HookStrictSelect, TransferLogModuleSelect>; } & Omit< UseMutationOptions< { createTransferLogModule: { transferLogModule: InferSelectResult; }; }, Error, CreateTransferLogModuleInput['transferLogModule'] >, 'mutationFn' > ): UseMutationResult< { createTransferLogModule: { transferLogModule: InferSelectResult; }; }, Error, CreateTransferLogModuleInput['transferLogModule'] >; export function useCreateTransferLogModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: transferLogModuleMutationKeys.create(), mutationFn: (data: CreateTransferLogModuleInput['transferLogModule']) => getClient() .transferLogModule.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: transferLogModuleKeys.lists(), }); }, ...mutationOptions, }); }