diff --git a/client/components/multi-uploader.js b/client/components/multi-uploader.js new file mode 100644 index 0000000..517ed04 --- /dev/null +++ b/client/components/multi-uploader.js @@ -0,0 +1,31 @@ +import {Component} from 'react' +import {graphql, gql} from 'react-apollo' + +class MultiUploader extends Component { + handleChange = ({target}) => { + if (target.validity.valid) { + this.props + .mutate({ + variables: { + files: target.files + } + }) + .then(({data}) => console.log('Mutation response:', data)) + } + } + + render () { + return + } +} + +export default graphql(gql` + mutation multiUpload ($files: [Upload!]) { + multiUpload (files: $files) { + name + type + size + path + } + } +`)(MultiUploader) diff --git a/client/pages/index.js b/client/pages/index.js index 26ad181..adbb4e3 100644 --- a/client/pages/index.js +++ b/client/pages/index.js @@ -1,6 +1,7 @@ import Head from 'next/head' import withData from '../helpers/with-data' import SingleUploader from '../components/single-uploader' +import MultiUploader from '../components/multi-uploader' export default withData(props => (
Select an image to upload and view the response in the console.
-Select an image to upload and view the response in the console.
+Select multiple images to upload and view the response in the console.
+