/** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * @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 { platformFunctionScheduleKeys } from '../query-keys'; import { platformFunctionScheduleMutationKeys } from '../mutation-keys'; import type { PlatformFunctionScheduleSelect, PlatformFunctionScheduleWithRelations, PlatformFunctionSchedulePatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformFunctionScheduleSelect, PlatformFunctionScheduleWithRelations, PlatformFunctionSchedulePatch, } from '../../orm/input-types'; /** * Function schedules — user-facing cron schedules synced into the worker scheduler (app_jobs.scheduled_jobs) * * @example * ```tsx * const { mutate, isPending } = useUpdatePlatformFunctionScheduleMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', platformFunctionSchedulePatch: { name: 'Updated' } }); * ``` */ export function useUpdatePlatformFunctionScheduleMutation( params: { selection: { fields: S & PlatformFunctionScheduleSelect; } & HookStrictSelect, PlatformFunctionScheduleSelect>; } & Omit< UseMutationOptions< { updatePlatformFunctionSchedule: { platformFunctionSchedule: InferSelectResult; }; }, Error, { id: string; platformFunctionSchedulePatch: PlatformFunctionSchedulePatch; } >, 'mutationFn' > ): UseMutationResult< { updatePlatformFunctionSchedule: { platformFunctionSchedule: InferSelectResult; }; }, Error, { id: string; platformFunctionSchedulePatch: PlatformFunctionSchedulePatch; } >; export function useUpdatePlatformFunctionScheduleMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; platformFunctionSchedulePatch: PlatformFunctionSchedulePatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformFunctionScheduleMutationKeys.all, mutationFn: ({ id, platformFunctionSchedulePatch, }: { id: string; platformFunctionSchedulePatch: PlatformFunctionSchedulePatch; }) => getClient() .platformFunctionSchedule.update({ where: { id, }, data: platformFunctionSchedulePatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: platformFunctionScheduleKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: platformFunctionScheduleKeys.lists(), }); }, ...mutationOptions, }); }