/** * Message within an agent thread with TextPart/ToolPart jsonb parts * @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 { platformAgentMessageKeys } from '../query-keys'; import { platformAgentMessageMutationKeys } from '../mutation-keys'; import type { PlatformAgentMessageSelect, PlatformAgentMessageWithRelations, CreatePlatformAgentMessageInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformAgentMessageSelect, PlatformAgentMessageWithRelations, CreatePlatformAgentMessageInput, } from '../../orm/input-types'; /** * Message within an agent thread with TextPart/ToolPart jsonb parts * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformAgentMessageMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformAgentMessageMutation( params: { selection: { fields: S & PlatformAgentMessageSelect; } & HookStrictSelect, PlatformAgentMessageSelect>; } & Omit< UseMutationOptions< { createPlatformAgentMessage: { platformAgentMessage: InferSelectResult; }; }, Error, CreatePlatformAgentMessageInput['platformAgentMessage'] >, 'mutationFn' > ): UseMutationResult< { createPlatformAgentMessage: { platformAgentMessage: InferSelectResult; }; }, Error, CreatePlatformAgentMessageInput['platformAgentMessage'] >; export function useCreatePlatformAgentMessageMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformAgentMessageMutationKeys.create(), mutationFn: (data: CreatePlatformAgentMessageInput['platformAgentMessage']) => getClient() .platformAgentMessage.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformAgentMessageKeys.lists(), }); }, ...mutationOptions, }); }