File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change 8
8
OperationVariables ,
9
9
QueryOptions ,
10
10
} from 'apollo-client' ;
11
+ import { DataProxy } from 'apollo-cache' ;
11
12
import { DocumentNode , ExecutionResult } from 'graphql' ;
12
13
import * as React from 'react' ;
13
14
@@ -52,10 +53,22 @@ export function useQuery<TData = any, TVariables = OperationVariables>(
52
53
) : Promise < ApolloQueryResult < TData > > ;
53
54
} ;
54
55
56
+ // We have to redefine MutationUpdaterFn and `update` option of `useMutation`
57
+ // hook because we want them to use our custom parametrized version
58
+ // of `FetchResult` type. Please look at
59
+ // https://github.com/trojanowski/react-apollo-hooks/issues/25
60
+ export type MutationUpdaterFn <
61
+ T = {
62
+ [ key : string ] : any ;
63
+ }
64
+ > = ( proxy : DataProxy , mutationResult : FetchResult < T > ) => void ;
65
+
55
66
type MutationHookOptions < T , TVariables > = Omit <
56
67
MutationOptions < T , TVariables > ,
57
- 'mutation'
58
- > ;
68
+ 'mutation' | 'update'
69
+ > & {
70
+ update ?: MutationUpdaterFn < T > ;
71
+ } ;
59
72
60
73
export function useMutation < T , TVariables = OperationVariables > (
61
74
mutation : DocumentNode ,
You can’t perform that action at this time.
0 commit comments