/** * Tracks per-actor usage counts against configurable maximum limits * @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 { orgLimitKeys } from '../query-keys'; import { orgLimitMutationKeys } from '../mutation-keys'; import type { OrgLimitSelect, OrgLimitWithRelations, OrgLimitPatch } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { OrgLimitSelect, OrgLimitWithRelations, OrgLimitPatch } from '../../orm/input-types'; /** * Tracks per-actor usage counts against configurable maximum limits * * @example * ```tsx * const { mutate, isPending } = useUpdateOrgLimitMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', orgLimitPatch: { name: 'Updated' } }); * ``` */ export function useUpdateOrgLimitMutation( params: { selection: { fields: S & OrgLimitSelect; } & HookStrictSelect, OrgLimitSelect>; } & Omit< UseMutationOptions< { updateOrgLimit: { orgLimit: InferSelectResult; }; }, Error, { id: string; orgLimitPatch: OrgLimitPatch; } >, 'mutationFn' > ): UseMutationResult< { updateOrgLimit: { orgLimit: InferSelectResult; }; }, Error, { id: string; orgLimitPatch: OrgLimitPatch; } >; export function useUpdateOrgLimitMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; orgLimitPatch: OrgLimitPatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: orgLimitMutationKeys.all, mutationFn: ({ id, orgLimitPatch }: { id: string; orgLimitPatch: OrgLimitPatch }) => getClient() .orgLimit.update({ where: { id, }, data: orgLimitPatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: orgLimitKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: orgLimitKeys.lists(), }); }, ...mutationOptions, }); }