/** * Branch heads — mutable pointers into the commit chain * @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 { databaseGraphRefKeys } from '../query-keys'; import { databaseGraphRefMutationKeys } from '../mutation-keys'; import type { DatabaseGraphRefSelect, DatabaseGraphRefWithRelations } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { DatabaseGraphRefSelect, DatabaseGraphRefWithRelations } from '../../orm/input-types'; /** * Branch heads — mutable pointers into the commit chain * * @example * ```tsx * const { mutate, isPending } = useDeleteDatabaseGraphRefMutation({ * selection: { fields: { id: true } }, * }); * * mutate({ id: 'value-to-delete' }); * ``` */ export function useDeleteDatabaseGraphRefMutation( params: { selection: { fields: S & DatabaseGraphRefSelect; } & HookStrictSelect, DatabaseGraphRefSelect>; } & Omit< UseMutationOptions< { deleteDatabaseGraphRef: { databaseGraphRef: InferSelectResult; }; }, Error, { id: string; databaseId: string; } >, 'mutationFn' > ): UseMutationResult< { deleteDatabaseGraphRef: { databaseGraphRef: InferSelectResult; }; }, Error, { id: string; databaseId: string; } >; export function useDeleteDatabaseGraphRefMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; databaseId: string; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: databaseGraphRefMutationKeys.all, mutationFn: ({ id, databaseId }: { id: string; databaseId: string }) => getClient() .databaseGraphRef.delete({ where: { id, databaseId, }, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.removeQueries({ queryKey: databaseGraphRefKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: databaseGraphRefKeys.lists(), }); }, ...mutationOptions, }); }