/** * Scope-aware plaintext internal config store. No namespace_module dependency and no K8s synchronization: values are read from the database at invocation time. Configuration that must be projected into a Kubernetes ConfigMap belongs in infra_config_module. * @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 { internalConfigModuleKeys } from '../query-keys'; import { internalConfigModuleMutationKeys } from '../mutation-keys'; import type { InternalConfigModuleSelect, InternalConfigModuleWithRelations, InternalConfigModulePatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { InternalConfigModuleSelect, InternalConfigModuleWithRelations, InternalConfigModulePatch, } from '../../orm/input-types'; /** * Scope-aware plaintext internal config store. No namespace_module dependency and no K8s synchronization: values are read from the database at invocation time. Configuration that must be projected into a Kubernetes ConfigMap belongs in infra_config_module. * * @example * ```tsx * const { mutate, isPending } = useUpdateInternalConfigModuleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', internalConfigModulePatch: { name: 'Updated' } }); * ``` */ export function useUpdateInternalConfigModuleMutation( params: { selection: { fields: S & InternalConfigModuleSelect; } & HookStrictSelect, InternalConfigModuleSelect>; } & Omit< UseMutationOptions< { updateInternalConfigModule: { internalConfigModule: InferSelectResult; }; }, Error, { id: string; internalConfigModulePatch: InternalConfigModulePatch; } >, 'mutationFn' > ): UseMutationResult< { updateInternalConfigModule: { internalConfigModule: InferSelectResult; }; }, Error, { id: string; internalConfigModulePatch: InternalConfigModulePatch; } >; export function useUpdateInternalConfigModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; internalConfigModulePatch: InternalConfigModulePatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: internalConfigModuleMutationKeys.all, mutationFn: ({ id, internalConfigModulePatch, }: { id: string; internalConfigModulePatch: InternalConfigModulePatch; }) => getClient() .internalConfigModule.update({ where: { id, }, data: internalConfigModulePatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: internalConfigModuleKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: internalConfigModuleKeys.lists(), }); }, ...mutationOptions, }); }