Jayden Seric 919c1d7a50 Update dependencies.
Includes prettier v2 lint fixes.
2020-03-30 13:00:27 +11:00

29 lines
646 B
JavaScript

import { useApolloClient, useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag'
const SINGLE_UPLOAD_MUTATION = gql`
mutation singleUpload($file: Upload!) {
singleUpload(file: $file) {
id
}
}
`
export const UploadFile = () => {
const [uploadFileMutation] = useMutation(SINGLE_UPLOAD_MUTATION)
const apolloClient = useApolloClient()
const onChange = ({
target: {
validity,
files: [file],
},
}) =>
validity.valid &&
uploadFileMutation({ variables: { file } }).then(() => {
apolloClient.resetStore()
})
return <input type="file" required onChange={onChange} />
}