/** * Create mutation hook for UserAuthModule * @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 { userAuthModuleKeys } from '../query-keys'; import { userAuthModuleMutationKeys } from '../mutation-keys'; import type { UserAuthModuleSelect, UserAuthModuleWithRelations, CreateUserAuthModuleInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { UserAuthModuleSelect, UserAuthModuleWithRelations, CreateUserAuthModuleInput, } from '../../orm/input-types'; /** * Mutation hook for creating a UserAuthModule * * @example * ```tsx * const { mutate, isPending } = useCreateUserAuthModuleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateUserAuthModuleMutation( params: { selection: { fields: S & UserAuthModuleSelect; } & HookStrictSelect, UserAuthModuleSelect>; } & Omit< UseMutationOptions< { createUserAuthModule: { userAuthModule: InferSelectResult; }; }, Error, CreateUserAuthModuleInput['userAuthModule'] >, 'mutationFn' > ): UseMutationResult< { createUserAuthModule: { userAuthModule: InferSelectResult; }; }, Error, CreateUserAuthModuleInput['userAuthModule'] >; export function useCreateUserAuthModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: userAuthModuleMutationKeys.create(), mutationFn: (data: CreateUserAuthModuleInput['userAuthModule']) => getClient() .userAuthModule.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: userAuthModuleKeys.lists(), }); }, ...mutationOptions, }); }