A big part of our main Feed.js file still consists of rendering the real form markup and using the Apollo Mutation component to pass and execute the mutation within the form. We will now separate those parts:
- Create a new folder for all your mutations, as follows:
mkdir src/client/components/mutations
- Next, we want to outsource the mutation into a special file. To do so, create the addPost.js file, named after the GraphQL mutation itself. Insert the following code:
export default class AddPostMutation extends Component { state = { postContent: '' } changePostContent = (value) => { this.setState({postContent: value}) } render() { const self = this; const { children, variables } = this.props; const { postContent ...