/** * Platform-operated hostnames whose DNS and certificate lifecycle the platform drives * @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 { platformManagedDomainKeys } from '../query-keys'; import { platformManagedDomainMutationKeys } from '../mutation-keys'; import type { PlatformManagedDomainSelect, PlatformManagedDomainWithRelations, CreatePlatformManagedDomainInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformManagedDomainSelect, PlatformManagedDomainWithRelations, CreatePlatformManagedDomainInput, } from '../../orm/input-types'; /** * Platform-operated hostnames whose DNS and certificate lifecycle the platform drives * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformManagedDomainMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformManagedDomainMutation( params: { selection: { fields: S & PlatformManagedDomainSelect; } & HookStrictSelect, PlatformManagedDomainSelect>; } & Omit< UseMutationOptions< { createPlatformManagedDomain: { platformManagedDomain: InferSelectResult; }; }, Error, CreatePlatformManagedDomainInput['platformManagedDomain'] >, 'mutationFn' > ): UseMutationResult< { createPlatformManagedDomain: { platformManagedDomain: InferSelectResult; }; }, Error, CreatePlatformManagedDomainInput['platformManagedDomain'] >; export function useCreatePlatformManagedDomainMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformManagedDomainMutationKeys.create(), mutationFn: (data: CreatePlatformManagedDomainInput['platformManagedDomain']) => getClient() .platformManagedDomain.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformManagedDomainKeys.lists(), }); }, ...mutationOptions, }); }