/** * Create mutation hook for ViewGrant * @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 { viewGrantKeys } from '../query-keys'; import { viewGrantMutationKeys } from '../mutation-keys'; import type { ViewGrantSelect, ViewGrantWithRelations, CreateViewGrantInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { ViewGrantSelect, ViewGrantWithRelations, CreateViewGrantInput, } from '../../orm/input-types'; /** * Mutation hook for creating a ViewGrant * * @example * ```tsx * const { mutate, isPending } = useCreateViewGrantMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateViewGrantMutation( params: { selection: { fields: S & ViewGrantSelect; } & HookStrictSelect, ViewGrantSelect>; } & Omit< UseMutationOptions< { createViewGrant: { viewGrant: InferSelectResult; }; }, Error, CreateViewGrantInput['viewGrant'] >, 'mutationFn' > ): UseMutationResult< { createViewGrant: { viewGrant: InferSelectResult; }; }, Error, CreateViewGrantInput['viewGrant'] >; export function useCreateViewGrantMutation( params: { selection: SelectionConfig; } & Omit, 'mutationFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: viewGrantMutationKeys.create(), mutationFn: (data: CreateViewGrantInput['viewGrant']) => getClient() .viewGrant.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: viewGrantKeys.lists(), }); }, ...mutationOptions, }); }