/** * Durable webhook acceptance log — one row per accepted delivery, deduplicated on (endpoint_id, external_event_id), linked to the pending function invocation it enqueued * @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 { webhookEventKeys } from '../query-keys'; import { webhookEventMutationKeys } from '../mutation-keys'; import type { WebhookEventSelect, WebhookEventWithRelations, WebhookEventPatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { WebhookEventSelect, WebhookEventWithRelations, WebhookEventPatch, } from '../../orm/input-types'; /** * Durable webhook acceptance log — one row per accepted delivery, deduplicated on (endpoint_id, external_event_id), linked to the pending function invocation it enqueued * * @example * ```tsx * const { mutate, isPending } = useUpdateWebhookEventMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', webhookEventPatch: { name: 'Updated' } }); * ``` */ export function useUpdateWebhookEventMutation( params: { selection: { fields: S & WebhookEventSelect; } & HookStrictSelect, WebhookEventSelect>; } & Omit< UseMutationOptions< { updateWebhookEvent: { webhookEvent: InferSelectResult; }; }, Error, { id: string; webhookEventPatch: WebhookEventPatch; } >, 'mutationFn' > ): UseMutationResult< { updateWebhookEvent: { webhookEvent: InferSelectResult; }; }, Error, { id: string; webhookEventPatch: WebhookEventPatch; } >; export function useUpdateWebhookEventMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; webhookEventPatch: WebhookEventPatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: webhookEventMutationKeys.all, mutationFn: ({ id, webhookEventPatch }: { id: string; webhookEventPatch: WebhookEventPatch }) => getClient() .webhookEvent.update({ where: { id, }, data: webhookEventPatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: webhookEventKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: webhookEventKeys.lists(), }); }, ...mutationOptions, }); }