/** * Per-preset configuration for the warm database pool: sizing, TTL, and the platform service org that owns unclaimed warm databases. * @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 { dbPoolConfigKeys } from '../query-keys'; import { dbPoolConfigMutationKeys } from '../mutation-keys'; import type { DbPoolConfigSelect, DbPoolConfigWithRelations, DbPoolConfigPatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { DbPoolConfigSelect, DbPoolConfigWithRelations, DbPoolConfigPatch, } from '../../orm/input-types'; /** * Per-preset configuration for the warm database pool: sizing, TTL, and the platform service org that owns unclaimed warm databases. * * @example * ```tsx * const { mutate, isPending } = useUpdateDbPoolConfigMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', dbPoolConfigPatch: { name: 'Updated' } }); * ``` */ export function useUpdateDbPoolConfigMutation( params: { selection: { fields: S & DbPoolConfigSelect; } & HookStrictSelect, DbPoolConfigSelect>; } & Omit< UseMutationOptions< { updateDbPoolConfig: { dbPoolConfig: InferSelectResult; }; }, Error, { id: string; dbPoolConfigPatch: DbPoolConfigPatch; } >, 'mutationFn' > ): UseMutationResult< { updateDbPoolConfig: { dbPoolConfig: InferSelectResult; }; }, Error, { id: string; dbPoolConfigPatch: DbPoolConfigPatch; } >; export function useUpdateDbPoolConfigMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; dbPoolConfigPatch: DbPoolConfigPatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: dbPoolConfigMutationKeys.all, mutationFn: ({ id, dbPoolConfigPatch }: { id: string; dbPoolConfigPatch: DbPoolConfigPatch }) => getClient() .dbPoolConfig.update({ where: { id, }, data: dbPoolConfigPatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: dbPoolConfigKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: dbPoolConfigKeys.lists(), }); }, ...mutationOptions, }); }