/** * One repository an agent run works in: its remote, branch, commits and how the work is published * @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 { platformAgentRunWorkspaceKeys } from '../query-keys'; import { platformAgentRunWorkspaceMutationKeys } from '../mutation-keys'; import type { PlatformAgentRunWorkspaceSelect, PlatformAgentRunWorkspaceWithRelations, PlatformAgentRunWorkspacePatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformAgentRunWorkspaceSelect, PlatformAgentRunWorkspaceWithRelations, PlatformAgentRunWorkspacePatch, } from '../../orm/input-types'; /** * One repository an agent run works in: its remote, branch, commits and how the work is published * * @example * ```tsx * const { mutate, isPending } = useUpdatePlatformAgentRunWorkspaceMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', platformAgentRunWorkspacePatch: { name: 'Updated' } }); * ``` */ export function useUpdatePlatformAgentRunWorkspaceMutation< S extends PlatformAgentRunWorkspaceSelect, >( params: { selection: { fields: S & PlatformAgentRunWorkspaceSelect; } & HookStrictSelect, PlatformAgentRunWorkspaceSelect>; } & Omit< UseMutationOptions< { updatePlatformAgentRunWorkspace: { platformAgentRunWorkspace: InferSelectResult; }; }, Error, { id: string; platformAgentRunWorkspacePatch: PlatformAgentRunWorkspacePatch; } >, 'mutationFn' > ): UseMutationResult< { updatePlatformAgentRunWorkspace: { platformAgentRunWorkspace: InferSelectResult; }; }, Error, { id: string; platformAgentRunWorkspacePatch: PlatformAgentRunWorkspacePatch; } >; export function useUpdatePlatformAgentRunWorkspaceMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; platformAgentRunWorkspacePatch: PlatformAgentRunWorkspacePatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformAgentRunWorkspaceMutationKeys.all, mutationFn: ({ id, platformAgentRunWorkspacePatch, }: { id: string; platformAgentRunWorkspacePatch: PlatformAgentRunWorkspacePatch; }) => getClient() .platformAgentRunWorkspace.update({ where: { id, }, data: platformAgentRunWorkspacePatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: platformAgentRunWorkspaceKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: platformAgentRunWorkspaceKeys.lists(), }); }, ...mutationOptions, }); }