@@ -8,8 +8,12 @@ import * as {{ properCase name }}ActionCreators from './actions';
88import cssModules from 'react-css-modules';
99import styles from './index.module.scss';
1010{{ /if }}
11+ {{ #if wantGraphQL }}
12+ import { graphql } from 'react-apollo';
13+ import gql from 'graphql-tag';
14+ {{ /if }}
1115
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
1317 render() {
1418 return (
1519 {{ #if wantSCSSModules }}
@@ -36,18 +40,52 @@ const mapDispatchToProps = (dispatch) => ({
3640 ),
3741});
3842{{ /if }}
39-
4043{{ #if wantSCSSModules }}
41- const Container = cssModules({{ properCase name }} , styles);
44+
45+ const Container = cssModules({{ properCase name }} Container, styles);
4246{{ else }}
43- const Container = {{ properCase name }} ;
47+
48+ const Container = {{ properCase name }} Container;
4449{{ /if }}
4550
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 }}
4674{{ #if wantActionsAndReducer }}
75+ {{ #if wantGraphQL }}
76+
77+ export default connect(
78+ mapStateToProps,
79+ mapDispatchToProps
80+ )(ContainerWithMutation);
81+ {{ else }}
82+
4783export default connect(
4884 mapStateToProps,
4985 mapDispatchToProps
5086)(Container);
87+ {{ /if }}
5188{{ else }}
89+
5290export default Container;
5391{{ /if }}
0 commit comments