/** * Commit history — each commit snapshots a tree root for a 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 { platformInfraCommitKeys } from '../query-keys'; import { platformInfraCommitMutationKeys } from '../mutation-keys'; import type { PlatformInfraCommitSelect, PlatformInfraCommitWithRelations, CreatePlatformInfraCommitInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformInfraCommitSelect, PlatformInfraCommitWithRelations, CreatePlatformInfraCommitInput, } from '../../orm/input-types'; /** * Commit history — each commit snapshots a tree root for a store * * @example * ```tsx * const { mutate, isPending } = useCreatePlatformInfraCommitMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformInfraCommitMutation( params: { selection: { fields: S & PlatformInfraCommitSelect; } & HookStrictSelect, PlatformInfraCommitSelect>; } & Omit< UseMutationOptions< { createPlatformInfraCommit: { platformInfraCommit: InferSelectResult; }; }, Error, CreatePlatformInfraCommitInput['platformInfraCommit'] >, 'mutationFn' > ): UseMutationResult< { createPlatformInfraCommit: { platformInfraCommit: InferSelectResult; }; }, Error, CreatePlatformInfraCommitInput['platformInfraCommit'] >; export function useCreatePlatformInfraCommitMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformInfraCommitMutationKeys.create(), mutationFn: (data: CreatePlatformInfraCommitInput['platformInfraCommit']) => getClient() .platformInfraCommit.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformInfraCommitKeys.lists(), }); }, ...mutationOptions, }); }