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 }