/** * Emoji reactions to a local proposal or one of its comments * @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 { platformProposalReactionKeys } from '../query-keys'; import { platformProposalReactionMutationKeys } from '../mutation-keys'; import type { PlatformProposalReactionSelect, PlatformProposalReactionWithRelations, CreatePlatformProposalReactionInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformProposalReactionSelect, PlatformProposalReactionWithRelations, CreatePlatformProposalReactionInput, } from '../../orm/input-types'; /** * Emoji reactions to a local proposal or one of its comments * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformProposalReactionMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformProposalReactionMutation( params: { selection: { fields: S & PlatformProposalReactionSelect; } & HookStrictSelect, PlatformProposalReactionSelect>; } & Omit< UseMutationOptions< { createPlatformProposalReaction: { platformProposalReaction: InferSelectResult; }; }, Error, CreatePlatformProposalReactionInput['platformProposalReaction'] >, 'mutationFn' > ): UseMutationResult< { createPlatformProposalReaction: { platformProposalReaction: InferSelectResult; }; }, Error, CreatePlatformProposalReactionInput['platformProposalReaction'] >; export function useCreatePlatformProposalReactionMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformProposalReactionMutationKeys.create(), mutationFn: (data: CreatePlatformProposalReactionInput['platformProposalReaction']) => getClient() .platformProposalReaction.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformProposalReactionKeys.lists(), }); }, ...mutationOptions, }); }