/** * Namespace lifecycle events — audit log of creation, activation, deactivation, label changes * @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 { platformNamespaceEventKeys } from '../query-keys'; import { platformNamespaceEventMutationKeys } from '../mutation-keys'; import type { PlatformNamespaceEventSelect, PlatformNamespaceEventWithRelations, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformNamespaceEventSelect, PlatformNamespaceEventWithRelations, } from '../../orm/input-types'; /** * Namespace lifecycle events — audit log of creation, activation, deactivation, label changes * * @example * ```tsx * const { mutate, isPending } = useDeletePlatformNamespaceEventMutation({ * selection: { fields: { id: true } }, * }); * * mutate({ id: 'value-to-delete' }); * ``` */ export function useDeletePlatformNamespaceEventMutation( params: { selection: { fields: S & PlatformNamespaceEventSelect; } & HookStrictSelect, PlatformNamespaceEventSelect>; } & Omit< UseMutationOptions< { deletePlatformNamespaceEvent: { platformNamespaceEvent: InferSelectResult; }; }, Error, { id: string; createdAt: string; } >, 'mutationFn' > ): UseMutationResult< { deletePlatformNamespaceEvent: { platformNamespaceEvent: InferSelectResult; }; }, Error, { id: string; createdAt: string; } >; export function useDeletePlatformNamespaceEventMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; createdAt: string; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformNamespaceEventMutationKeys.all, mutationFn: ({ id, createdAt }: { id: string; createdAt: string }) => getClient() .platformNamespaceEvent.delete({ where: { id, createdAt, }, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.removeQueries({ queryKey: platformNamespaceEventKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: platformNamespaceEventKeys.lists(), }); }, ...mutationOptions, }); }