/** * Function deployment bindings — ties a handler image to a namespace for Knative provisioning and routing (one row per handler image per namespace) * @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 { functionDeploymentKeys } from '../query-keys'; import { functionDeploymentMutationKeys } from '../mutation-keys'; import type { FunctionDeploymentSelect, FunctionDeploymentWithRelations, CreateFunctionDeploymentInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { FunctionDeploymentSelect, FunctionDeploymentWithRelations, CreateFunctionDeploymentInput, } from '../../orm/input-types'; /** * Function deployment bindings — ties a handler image to a namespace for Knative provisioning and routing (one row per handler image per namespace) * * @example * ```tsx * const { mutate, isPending } = useCreateFunctionDeploymentMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateFunctionDeploymentMutation( params: { selection: { fields: S & FunctionDeploymentSelect; } & HookStrictSelect, FunctionDeploymentSelect>; } & Omit< UseMutationOptions< { createFunctionDeployment: { functionDeployment: InferSelectResult; }; }, Error, CreateFunctionDeploymentInput['functionDeployment'] >, 'mutationFn' > ): UseMutationResult< { createFunctionDeployment: { functionDeployment: InferSelectResult; }; }, Error, CreateFunctionDeploymentInput['functionDeployment'] >; export function useCreateFunctionDeploymentMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: functionDeploymentMutationKeys.create(), mutationFn: (data: CreateFunctionDeploymentInput['functionDeployment']) => getClient() .functionDeployment.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: functionDeploymentKeys.lists(), }); }, ...mutationOptions, }); }