File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,9 @@ import hoistNonReactStatics from 'hoist-non-react-statics';
10
10
export { compose } from 'react-apollo' ;
11
11
12
12
13
+ const prefix = '@@MUTATION/'
14
+
15
+
13
16
function reduxGraphql ( options ) {
14
17
return ( Component ) => class ReduxGraphql extends React . Component {
15
18
render ( ) {
@@ -24,20 +27,23 @@ function reduxGraphql(options) {
24
27
const { dispatch } = this . props ;
25
28
return async ( ...args ) => {
26
29
dispatch ( {
27
- type : options . name | > snakeCase | > toUpper ,
30
+ type : prefix + options . name | > snakeCase | > toUpper ,
28
31
payload : args [ 0 ] ,
29
32
} ) ;
30
33
try {
31
34
const result = await mutation ( ...args ) ;
32
35
dispatch ( {
33
- type : options . name + '_success' | > snakeCase | > toUpper ,
34
- payload : result ,
36
+ type : prefix + options . name + '_success' | > snakeCase | > toUpper ,
37
+ payload : {
38
+ result,
39
+ args : args [ 0 ] ,
40
+ }
35
41
} ) ;
36
42
return result ;
37
43
}
38
44
catch ( error ) {
39
45
dispatch ( {
40
- type : options . name + '_fail' | > snakeCase | > toUpper ,
46
+ type : prefix + options . name + '_fail' | > snakeCase | > toUpper ,
41
47
meta : { error } ,
42
48
} ) ;
43
49
throw error ;
You can’t perform that action at this time.
0 commit comments