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