/** * Namespace-backed plaintext key-value config module. Requires namespace_module and emits namespace:sync_config job triggers for K8s ConfigMap synchronization. * @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 { infraConfigModuleKeys } from '../query-keys'; import { infraConfigModuleMutationKeys } from '../mutation-keys'; import type { InfraConfigModuleSelect, InfraConfigModuleWithRelations, CreateInfraConfigModuleInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { InfraConfigModuleSelect, InfraConfigModuleWithRelations, CreateInfraConfigModuleInput, } from '../../orm/input-types'; /** * Namespace-backed plaintext key-value config module. Requires namespace_module and emits namespace:sync_config job triggers for K8s ConfigMap synchronization. * * @example * ```tsx * const { mutate, isPending } = useCreateInfraConfigModuleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateInfraConfigModuleMutation( params: { selection: { fields: S & InfraConfigModuleSelect; } & HookStrictSelect, InfraConfigModuleSelect>; } & Omit< UseMutationOptions< { createInfraConfigModule: { infraConfigModule: InferSelectResult; }; }, Error, CreateInfraConfigModuleInput['infraConfigModule'] >, 'mutationFn' > ): UseMutationResult< { createInfraConfigModule: { infraConfigModule: InferSelectResult; }; }, Error, CreateInfraConfigModuleInput['infraConfigModule'] >; export function useCreateInfraConfigModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: infraConfigModuleMutationKeys.create(), mutationFn: (data: CreateInfraConfigModuleInput['infraConfigModule']) => getClient() .infraConfigModule.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: infraConfigModuleKeys.lists(), }); }, ...mutationOptions, }); }