/** * Task within a plan, with ordering and optional approval gates * @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 { platformAgentTaskKeys } from '../query-keys'; import { platformAgentTaskMutationKeys } from '../mutation-keys'; import type { PlatformAgentTaskSelect, PlatformAgentTaskWithRelations, CreatePlatformAgentTaskInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformAgentTaskSelect, PlatformAgentTaskWithRelations, CreatePlatformAgentTaskInput, } from '../../orm/input-types'; /** * Task within a plan, with ordering and optional approval gates * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformAgentTaskMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformAgentTaskMutation( params: { selection: { fields: S & PlatformAgentTaskSelect; } & HookStrictSelect, PlatformAgentTaskSelect>; } & Omit< UseMutationOptions< { createPlatformAgentTask: { platformAgentTask: InferSelectResult; }; }, Error, CreatePlatformAgentTaskInput['platformAgentTask'] >, 'mutationFn' > ): UseMutationResult< { createPlatformAgentTask: { platformAgentTask: InferSelectResult; }; }, Error, CreatePlatformAgentTaskInput['platformAgentTask'] >; export function useCreatePlatformAgentTaskMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformAgentTaskMutationKeys.create(), mutationFn: (data: CreatePlatformAgentTaskInput['platformAgentTask']) => getClient() .platformAgentTask.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformAgentTaskKeys.lists(), }); }, ...mutationOptions, }); }