/** * Seed-content preset catalog (limit defaults, trust ladders, ...) — merkle-versioned head over the infra store * @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 { contentPresetKeys } from '../query-keys'; import { contentPresetMutationKeys } from '../mutation-keys'; import type { ContentPresetSelect, ContentPresetWithRelations, CreateContentPresetInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { ContentPresetSelect, ContentPresetWithRelations, CreateContentPresetInput, } from '../../orm/input-types'; /** * Seed-content preset catalog (limit defaults, trust ladders, ...) — merkle-versioned head over the infra store * * @example * ```tsx * const { mutate, isPending } = useCreateContentPresetMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateContentPresetMutation( params: { selection: { fields: S & ContentPresetSelect; } & HookStrictSelect, ContentPresetSelect>; } & Omit< UseMutationOptions< { createContentPreset: { contentPreset: InferSelectResult; }; }, Error, CreateContentPresetInput['contentPreset'] >, 'mutationFn' > ): UseMutationResult< { createContentPreset: { contentPreset: InferSelectResult; }; }, Error, CreateContentPresetInput['contentPreset'] >; export function useCreateContentPresetMutation( params: { selection: SelectionConfig; } & Omit, 'mutationFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: contentPresetMutationKeys.create(), mutationFn: (data: CreateContentPresetInput['contentPreset']) => getClient() .contentPreset.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: contentPresetKeys.lists(), }); }, ...mutationOptions, }); }