/** * Top-level AI/LLM conversation thread * @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 { platformAgentThreadKeys } from '../query-keys'; import { platformAgentThreadMutationKeys } from '../mutation-keys'; import type { PlatformAgentThreadSelect, PlatformAgentThreadWithRelations, CreatePlatformAgentThreadInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformAgentThreadSelect, PlatformAgentThreadWithRelations, CreatePlatformAgentThreadInput, } from '../../orm/input-types'; /** * Top-level AI/LLM conversation thread * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformAgentThreadMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformAgentThreadMutation( params: { selection: { fields: S & PlatformAgentThreadSelect; } & HookStrictSelect, PlatformAgentThreadSelect>; } & Omit< UseMutationOptions< { createPlatformAgentThread: { platformAgentThread: InferSelectResult; }; }, Error, CreatePlatformAgentThreadInput['platformAgentThread'] >, 'mutationFn' > ): UseMutationResult< { createPlatformAgentThread: { platformAgentThread: InferSelectResult; }; }, Error, CreatePlatformAgentThreadInput['platformAgentThread'] >; export function useCreatePlatformAgentThreadMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformAgentThreadMutationKeys.create(), mutationFn: (data: CreatePlatformAgentThreadInput['platformAgentThread']) => getClient() .platformAgentThread.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformAgentThreadKeys.lists(), }); }, ...mutationOptions, }); }