/** * A tenant's configured account at an email provider: provider slug, endpoint coordinates, and the NAME of the secret holding its credentials (never the credential itself) * @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 { platformEmailProviderAccountKeys } from '../query-keys'; import { platformEmailProviderAccountMutationKeys } from '../mutation-keys'; import type { PlatformEmailProviderAccountSelect, PlatformEmailProviderAccountWithRelations, CreatePlatformEmailProviderAccountInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformEmailProviderAccountSelect, PlatformEmailProviderAccountWithRelations, CreatePlatformEmailProviderAccountInput, } from '../../orm/input-types'; /** * A tenant's configured account at an email provider: provider slug, endpoint coordinates, and the NAME of the secret holding its credentials (never the credential itself) * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformEmailProviderAccountMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformEmailProviderAccountMutation< S extends PlatformEmailProviderAccountSelect, >( params: { selection: { fields: S & PlatformEmailProviderAccountSelect; } & HookStrictSelect, PlatformEmailProviderAccountSelect>; } & Omit< UseMutationOptions< { createPlatformEmailProviderAccount: { platformEmailProviderAccount: InferSelectResult< PlatformEmailProviderAccountWithRelations, S >; }; }, Error, CreatePlatformEmailProviderAccountInput['platformEmailProviderAccount'] >, 'mutationFn' > ): UseMutationResult< { createPlatformEmailProviderAccount: { platformEmailProviderAccount: InferSelectResult; }; }, Error, CreatePlatformEmailProviderAccountInput['platformEmailProviderAccount'] >; export function useCreatePlatformEmailProviderAccountMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, CreatePlatformEmailProviderAccountInput['platformEmailProviderAccount'] >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformEmailProviderAccountMutationKeys.create(), mutationFn: (data: CreatePlatformEmailProviderAccountInput['platformEmailProviderAccount']) => getClient() .platformEmailProviderAccount.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformEmailProviderAccountKeys.lists(), }); }, ...mutationOptions, }); }