/** * Append-only log of limit events for historical reporting and audit * @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 { orgLimitEventKeys } from '../query-keys'; import { orgLimitEventMutationKeys } from '../mutation-keys'; import type { OrgLimitEventSelect, OrgLimitEventWithRelations, OrgLimitEventPatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { OrgLimitEventSelect, OrgLimitEventWithRelations, OrgLimitEventPatch, } from '../../orm/input-types'; /** * Append-only log of limit events for historical reporting and audit * * @example * ```tsx * const { mutate, isPending } = useUpdateOrgLimitEventMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', orgLimitEventPatch: { name: 'Updated' } }); * ``` */ export function useUpdateOrgLimitEventMutation( params: { selection: { fields: S & OrgLimitEventSelect; } & HookStrictSelect, OrgLimitEventSelect>; } & Omit< UseMutationOptions< { updateOrgLimitEvent: { orgLimitEvent: InferSelectResult; }; }, Error, { id: string; createdAt: string; orgLimitEventPatch: OrgLimitEventPatch; } >, 'mutationFn' > ): UseMutationResult< { updateOrgLimitEvent: { orgLimitEvent: InferSelectResult; }; }, Error, { id: string; createdAt: string; orgLimitEventPatch: OrgLimitEventPatch; } >; export function useUpdateOrgLimitEventMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; createdAt: string; orgLimitEventPatch: OrgLimitEventPatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: orgLimitEventMutationKeys.all, mutationFn: ({ id, createdAt, orgLimitEventPatch, }: { id: string; createdAt: string; orgLimitEventPatch: OrgLimitEventPatch; }) => getClient() .orgLimitEvent.update({ where: { id, createdAt, }, data: orgLimitEventPatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: orgLimitEventKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: orgLimitEventKeys.lists(), }); }, ...mutationOptions, }); }