/** * 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 { platformWebhookEventKeys } from '../query-keys'; import { platformWebhookEventMutationKeys } from '../mutation-keys'; import type { PlatformWebhookEventSelect, PlatformWebhookEventWithRelations, CreatePlatformWebhookEventInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformWebhookEventSelect, PlatformWebhookEventWithRelations, CreatePlatformWebhookEventInput, } 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 } = useCreatePlatformWebhookEventMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformWebhookEventMutation( params: { selection: { fields: S & PlatformWebhookEventSelect; } & HookStrictSelect, PlatformWebhookEventSelect>; } & Omit< UseMutationOptions< { createPlatformWebhookEvent: { platformWebhookEvent: InferSelectResult; }; }, Error, CreatePlatformWebhookEventInput['platformWebhookEvent'] >, 'mutationFn' > ): UseMutationResult< { createPlatformWebhookEvent: { platformWebhookEvent: InferSelectResult; }; }, Error, CreatePlatformWebhookEventInput['platformWebhookEvent'] >; export function useCreatePlatformWebhookEventMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformWebhookEventMutationKeys.create(), mutationFn: (data: CreatePlatformWebhookEventInput['platformWebhookEvent']) => getClient() .platformWebhookEvent.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformWebhookEventKeys.lists(), }); }, ...mutationOptions, }); }