@@ -3,7 +3,7 @@ import { get, globalActionOperation, namespaceDataPath } from "@gadgetinc/api-cl
3
3
import { useCallback , useEffect , useMemo } from "react" ;
4
4
import type { OperationContext , UseMutationState } from "urql" ;
5
5
import { useGadgetMutation } from "./useGadgetMutation.js" ;
6
- import type { ActionHookResult } from "./utils.js" ;
6
+ import type { ActionHookResultWithOptionalCallbackVariables } from "./utils.js" ;
7
7
import { ErrorWrapper } from "./utils.js" ;
8
8
9
9
/**
@@ -29,7 +29,7 @@ import { ErrorWrapper } from "./utils.js";
29
29
*/
30
30
export const useGlobalAction = < F extends GlobalActionFunction < any > > (
31
31
action : F
32
- ) : ActionHookResult < any , Exclude < F [ "variablesType" ] , null | undefined > > => {
32
+ ) : ActionHookResultWithOptionalCallbackVariables < any , Exclude < F [ "variablesType" ] , null | undefined > > => {
33
33
useEffect ( ( ) => {
34
34
if ( action . type === ( "stubbedAction" as string ) ) {
35
35
const stubbedAction = action as unknown as StubbedActionFunction < any > ;
@@ -63,8 +63,8 @@ export const useGlobalAction = <F extends GlobalActionFunction<any>>(
63
63
return [
64
64
transformedResult ,
65
65
useCallback (
66
- async ( variables : F [ "variablesType" ] , context ?: Partial < OperationContext > ) => {
67
- const result = await runMutation ( variables , context ) ;
66
+ async ( variables ? : F [ "variablesType" ] , context ?: Partial < OperationContext > ) => {
67
+ const result = await runMutation ( variables ?? { } , context ) ;
68
68
return processResult ( { fetching : false , ...result } , action ) ;
69
69
} ,
70
70
[ action , runMutation ]
0 commit comments