/** * Named, retargetable deep links owned by a site surface (served at the deep-link path prefix; app interception via site_app_links) * @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 { siteDeepLinkKeys } from '../query-keys'; import { siteDeepLinkMutationKeys } from '../mutation-keys'; import type { SiteDeepLinkSelect, SiteDeepLinkWithRelations, CreateSiteDeepLinkInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { SiteDeepLinkSelect, SiteDeepLinkWithRelations, CreateSiteDeepLinkInput, } from '../../orm/input-types'; /** * Named, retargetable deep links owned by a site surface (served at the deep-link path prefix; app interception via site_app_links) * * @example * ```tsx * const { mutate, isPending } = useCreateSiteDeepLinkMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateSiteDeepLinkMutation( params: { selection: { fields: S & SiteDeepLinkSelect; } & HookStrictSelect, SiteDeepLinkSelect>; } & Omit< UseMutationOptions< { createSiteDeepLink: { siteDeepLink: InferSelectResult; }; }, Error, CreateSiteDeepLinkInput['siteDeepLink'] >, 'mutationFn' > ): UseMutationResult< { createSiteDeepLink: { siteDeepLink: InferSelectResult; }; }, Error, CreateSiteDeepLinkInput['siteDeepLink'] >; export function useCreateSiteDeepLinkMutation( params: { selection: SelectionConfig; } & Omit, 'mutationFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: siteDeepLinkMutationKeys.create(), mutationFn: (data: CreateSiteDeepLinkInput['siteDeepLink']) => getClient() .siteDeepLink.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: siteDeepLinkKeys.lists(), }); }, ...mutationOptions, }); }