/** * Per-host native-app association for a site surface: which app-owned store identity this host serves, and the path patterns it claims (joined with the store identity to render AASA / assetlinks.json) * @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 { siteAppLinkKeys } from '../query-keys'; import { siteAppLinkMutationKeys } from '../mutation-keys'; import type { SiteAppLinkSelect, SiteAppLinkWithRelations, CreateSiteAppLinkInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { SiteAppLinkSelect, SiteAppLinkWithRelations, CreateSiteAppLinkInput, } from '../../orm/input-types'; /** * Per-host native-app association for a site surface: which app-owned store identity this host serves, and the path patterns it claims (joined with the store identity to render AASA / assetlinks.json) * * @example * ```tsx * const { mutate, isPending } = useCreateSiteAppLinkMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreateSiteAppLinkMutation( params: { selection: { fields: S & SiteAppLinkSelect; } & HookStrictSelect, SiteAppLinkSelect>; } & Omit< UseMutationOptions< { createSiteAppLink: { siteAppLink: InferSelectResult; }; }, Error, CreateSiteAppLinkInput['siteAppLink'] >, 'mutationFn' > ): UseMutationResult< { createSiteAppLink: { siteAppLink: InferSelectResult; }; }, Error, CreateSiteAppLinkInput['siteAppLink'] >; export function useCreateSiteAppLinkMutation( params: { selection: SelectionConfig; } & Omit, 'mutationFn'> ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: siteAppLinkMutationKeys.create(), mutationFn: (data: CreateSiteAppLinkInput['siteAppLink']) => getClient() .siteAppLink.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: siteAppLinkKeys.lists(), }); }, ...mutationOptions, }); }