@@ -8,8 +8,12 @@ import * as {{ properCase name }}ActionCreators from './actions';
8
8
import cssModules from 'react-css-modules';
9
9
import styles from './index.module.scss';
10
10
{{ /if }}
11
+ {{ #if wantGraphQL }}
12
+ import { graphql } from 'react-apollo';
13
+ import gql from 'graphql-tag';
14
+ {{ /if }}
11
15
12
- class {{ properCase name }} extends Component { // eslint-disable-line react/prefer-stateless-function
16
+ class {{ properCase name }} Container extends Component { // eslint-disable-line react/prefer-stateless-function
13
17
render() {
14
18
return (
15
19
{{ #if wantSCSSModules }}
@@ -36,18 +40,52 @@ const mapDispatchToProps = (dispatch) => ({
36
40
),
37
41
});
38
42
{{ /if }}
39
-
40
43
{{ #if wantSCSSModules }}
41
- const Container = cssModules({{ properCase name }} , styles);
44
+
45
+ const Container = cssModules({{ properCase name }} Container, styles);
42
46
{{ else }}
43
- const Container = {{ properCase name }} ;
47
+
48
+ const Container = {{ properCase name }} Container;
44
49
{{ /if }}
45
50
51
+ {{ #if wantGraphQL }}
52
+ const {{ camelCase name }} Query = gql`
53
+ query {{ camelCase name }} {
54
+ id
55
+ }
56
+ `;
57
+
58
+ const ContainerWithData = graphql({{ camelCase name }} Query, {
59
+ props: ({ data: { loading, error, {{ camelCase name }} } }) => ({
60
+ {{ camelCase name }} ,
61
+ loading,
62
+ error,
63
+ }),
64
+ })(Container);
65
+
66
+ const {{ camelCase name }} Mutation = gql`
67
+ mutation {{ camelCase name }} {
68
+ id
69
+ }
70
+ `;
71
+
72
+ const ContainerWithMutation = graphql({{ camelCase name }} Mutation)(ContainerWithData);
73
+ {{ /if }}
46
74
{{ #if wantActionsAndReducer }}
75
+ {{ #if wantGraphQL }}
76
+
77
+ export default connect(
78
+ mapStateToProps,
79
+ mapDispatchToProps
80
+ )(ContainerWithMutation);
81
+ {{ else }}
82
+
47
83
export default connect(
48
84
mapStateToProps,
49
85
mapDispatchToProps
50
86
)(Container);
87
+ {{ /if }}
51
88
{{ else }}
89
+
52
90
export default Container;
53
91
{{ /if }}
0 commit comments