/** * Update mutation hook for FunctionDeploymentModule * @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 { functionDeploymentModuleKeys } from '../query-keys'; import { functionDeploymentModuleMutationKeys } from '../mutation-keys'; import type { FunctionDeploymentModuleSelect, FunctionDeploymentModuleWithRelations, FunctionDeploymentModulePatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { FunctionDeploymentModuleSelect, FunctionDeploymentModuleWithRelations, FunctionDeploymentModulePatch, } from '../../orm/input-types'; /** * Mutation hook for updating a FunctionDeploymentModule * * @example * ```tsx * const { mutate, isPending } = useUpdateFunctionDeploymentModuleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', functionDeploymentModulePatch: { name: 'Updated' } }); * ``` */ export function useUpdateFunctionDeploymentModuleMutation( params: { selection: { fields: S & FunctionDeploymentModuleSelect; } & HookStrictSelect, FunctionDeploymentModuleSelect>; } & Omit< UseMutationOptions< { updateFunctionDeploymentModule: { functionDeploymentModule: InferSelectResult; }; }, Error, { id: string; functionDeploymentModulePatch: FunctionDeploymentModulePatch; } >, 'mutationFn' > ): UseMutationResult< { updateFunctionDeploymentModule: { functionDeploymentModule: InferSelectResult; }; }, Error, { id: string; functionDeploymentModulePatch: FunctionDeploymentModulePatch; } >; export function useUpdateFunctionDeploymentModuleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; functionDeploymentModulePatch: FunctionDeploymentModulePatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: functionDeploymentModuleMutationKeys.all, mutationFn: ({ id, functionDeploymentModulePatch, }: { id: string; functionDeploymentModulePatch: FunctionDeploymentModulePatch; }) => getClient() .functionDeploymentModule.update({ where: { id, }, data: functionDeploymentModulePatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: functionDeploymentModuleKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: functionDeploymentModuleKeys.lists(), }); }, ...mutationOptions, }); }