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