/** * Partitioned append-only audit log of authentication events (sign-in, sign-up, password changes, etc.) * @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 { auditLogAuthKeys } from '../query-keys'; import { auditLogAuthMutationKeys } from '../mutation-keys'; import type { AuditLogAuthSelect, AuditLogAuthWithRelations, CreateAuditLogAuthInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { AuditLogAuthSelect, AuditLogAuthWithRelations, CreateAuditLogAuthInput, } from '../../orm/input-types'; /** * Partitioned append-only audit log of authentication events (sign-in, sign-up, password changes, etc.) * * @example * ```tsx * const { mutate, isPending } = useCreateAuditLogAuthMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateAuditLogAuthMutation( params: { selection: { fields: S & AuditLogAuthSelect; } & HookStrictSelect, AuditLogAuthSelect>; } & Omit< UseMutationOptions< { createAuditLogAuth: { auditLogAuth: InferSelectResult; }; }, Error, CreateAuditLogAuthInput['auditLogAuth'] >, 'mutationFn' > ): UseMutationResult< { createAuditLogAuth: { auditLogAuth: InferSelectResult; }; }, Error, CreateAuditLogAuthInput['auditLogAuth'] >; export function useCreateAuditLogAuthMutation( params: { selection: SelectionConfig; } & Omit, 'mutationFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: auditLogAuthMutationKeys.create(), mutationFn: (data: CreateAuditLogAuthInput['auditLogAuth']) => getClient() .auditLogAuth.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: auditLogAuthKeys.lists(), }); }, ...mutationOptions, }); }