/** * Delete mutation hook for RefusalLogModule * @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 { refusalLogModuleKeys } from '../query-keys'; import { refusalLogModuleMutationKeys } from '../mutation-keys'; import type { RefusalLogModuleSelect, RefusalLogModuleWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { RefusalLogModuleSelect, RefusalLogModuleWithRelations } from '../../orm/input-types'; /** * Mutation hook for deleting a RefusalLogModule with typed selection * * @example * ```tsx * const { mutate, isPending } = useDeleteRefusalLogModuleMutation({ * selection: { fields: { id: true } }, * }); * * mutate({ id: 'value-to-delete' }); * ``` */ export function useDeleteRefusalLogModuleMutation( params: { selection: { fields: S & RefusalLogModuleSelect; } & HookStrictSelect, RefusalLogModuleSelect>; } & Omit< UseMutationOptions< { deleteRefusalLogModule: { refusalLogModule: InferSelectResult; }; }, Error, { id: string; } >, 'mutationFn' > ): UseMutationResult< { deleteRefusalLogModule: { refusalLogModule: InferSelectResult; }; }, Error, { id: string; } >; export function useDeleteRefusalLogModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: refusalLogModuleMutationKeys.all, mutationFn: ({ id }: { id: string }) => getClient() .refusalLogModule.delete({ where: { id, }, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.removeQueries({ queryKey: refusalLogModuleKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: refusalLogModuleKeys.lists(), }); }, ...mutationOptions, }); }