import { GQlessClient, GQlessError, RetryOptions } from 'gqless'; import { OnErrorHandler } from '../common'; import { ReactClientOptionsWithDefaults } from '../utils'; export interface UseMutationOptions { noCache?: boolean; onCompleted?: (data: TData) => void; onError?: OnErrorHandler; /** * Retry behaviour * * @default false */ retry?: RetryOptions; /** * Refetch specific queries after mutation completion. * * You can give functions or parts of the schema to be refetched */ refetchQueries?: unknown[]; /** * Await refetch resolutions before calling the mutation actually complete */ awaitRefetchQueries?: boolean; /** * Enable suspense behavior */ suspense?: boolean; /** * Activate special handling of non-serializable variables, * for example, files uploading * * @default false */ nonSerializableVariables?: boolean; } export interface UseMutationState { data: TData | undefined; error?: GQlessError; isLoading: boolean; } export interface UseMutation { (mutationFn?: (mutation: GeneratedSchema['mutation'], args: TArgs) => TData, options?: UseMutationOptions): readonly [ (...opts: undefined extends TArgs ? [ { fn?: (mutation: GeneratedSchema['mutation'], args: TArgs) => TData; args?: TArgs; }? ] : [ { fn?: (mutation: GeneratedSchema['mutation'], args: TArgs) => TData; args: TArgs; } ]) => Promise, UseMutationState ]; } export declare function createUseMutation(client: GQlessClient, { defaults: { mutationSuspense: defaultSuspense }, }: ReactClientOptionsWithDefaults): UseMutation;