/** * 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 { platformSiteAppLinkKeys } from '../query-keys'; import { platformSiteAppLinkMutationKeys } from '../mutation-keys'; import type { PlatformSiteAppLinkSelect, PlatformSiteAppLinkWithRelations, CreatePlatformSiteAppLinkInput, } from '../../orm/input-types'; import type { InferSelectResult, HookStrictSelect } from '../../orm/select-types'; export type { PlatformSiteAppLinkSelect, PlatformSiteAppLinkWithRelations, CreatePlatformSiteAppLinkInput, } 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 } = useCreatePlatformSiteAppLinkMutation({ * selection: { fields: { id: true, name: true } }, * }); * * mutate({ name: 'New item' }); * ``` */ export function useCreatePlatformSiteAppLinkMutation( params: { selection: { fields: S & PlatformSiteAppLinkSelect; } & HookStrictSelect, PlatformSiteAppLinkSelect>; } & Omit< UseMutationOptions< { createPlatformSiteAppLink: { platformSiteAppLink: InferSelectResult; }; }, Error, CreatePlatformSiteAppLinkInput['platformSiteAppLink'] >, 'mutationFn' > ): UseMutationResult< { createPlatformSiteAppLink: { platformSiteAppLink: InferSelectResult; }; }, Error, CreatePlatformSiteAppLinkInput['platformSiteAppLink'] >; export function useCreatePlatformSiteAppLinkMutation( params: { selection: SelectionConfig; } & Omit< UseMutationOptions, 'mutationFn' > ) { const args = buildSelectionArgs(params.selection); const { selection: _selection, ...mutationOptions } = params ?? {}; void _selection; const queryClient = useQueryClient(); return useMutation({ mutationKey: platformSiteAppLinkMutationKeys.create(), mutationFn: (data: CreatePlatformSiteAppLinkInput['platformSiteAppLink']) => getClient() .platformSiteAppLink.create({ data, select: args.select, }) .unwrap(), onSuccess: () => { queryClient.invalidateQueries({ queryKey: platformSiteAppLinkKeys.lists(), }); }, ...mutationOptions, }); }