/** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle 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 { databaseFunctionGraphKeys } from '../query-keys'; import { databaseFunctionGraphMutationKeys } from '../mutation-keys'; import type { DatabaseFunctionGraphSelect, DatabaseFunctionGraphWithRelations, DatabaseFunctionGraphPatch, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { DatabaseFunctionGraphSelect, DatabaseFunctionGraphWithRelations, DatabaseFunctionGraphPatch, } from '../../orm/input-types'; /** * Flow graph definitions — FBP graphs stored in the dedicated graph Merkle store * * @example * ```tsx * const { mutate, isPending } = useUpdateDatabaseFunctionGraphMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ id: 'value-here', databaseFunctionGraphPatch: { name: 'Updated' } }); * ``` */ export function useUpdateDatabaseFunctionGraphMutation( params: { selection: { fields: S & DatabaseFunctionGraphSelect; } & HookStrictSelect, DatabaseFunctionGraphSelect>; } & Omit< UseMutationOptions< { updateDatabaseFunctionGraph: { databaseFunctionGraph: InferSelectResult; }; }, Error, { id: string; databaseFunctionGraphPatch: DatabaseFunctionGraphPatch; } >, 'mutationFn' > ): UseMutationResult< { updateDatabaseFunctionGraph: { databaseFunctionGraph: InferSelectResult; }; }, Error, { id: string; databaseFunctionGraphPatch: DatabaseFunctionGraphPatch; } >; export function useUpdateDatabaseFunctionGraphMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions< any, Error, { id: string; databaseFunctionGraphPatch: DatabaseFunctionGraphPatch; } >, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: databaseFunctionGraphMutationKeys.all, mutationFn: ({ id, databaseFunctionGraphPatch, }: { id: string; databaseFunctionGraphPatch: DatabaseFunctionGraphPatch; }) => getClient() .databaseFunctionGraph.update({ where: { id, }, data: databaseFunctionGraphPatch, select: args.select, }) .unwrap(), onSuccess: (_, variables) => { queryClient.invalidateQueries({ queryKey: databaseFunctionGraphKeys.detail(variables.id), }); queryClient.invalidateQueries({ queryKey: databaseFunctionGraphKeys.lists(), }); }, ...mutationOptions, }); }