need help to debug fileupload for a given mutation

  • Stato: Pending
  • Premio: ₹5000
  • Proposte ricevute: 1

Descrizione del concorso

I tried example (https://github.com/jaydenseric/apollo-upload-examples) both api and app are working fine. I created my own client and tried and its not working. its sending null object to server.
What I need help in debug my client code provided as below pointing to the server(https://github.com/jaydenseric/apollo-upload-examples/tree/master/api) and it should work
Since its sending null object so I am getting error "createReadStream is not a function" in both client and server. Would you pls help me to resolve this issue
Please find my my client code details and mutation details as follows(which need to work for a single file upload:
Here is my client .
import React from 'react';
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
}
}
`
const UploadFile = () => {
const [uploadFile,{error}] = useMutation(SINGLE_UPLOAD_MUTATION);
const [uploadFileMutation] = useMutation(SINGLE_UPLOAD_MUTATION)
const onChange = ({
target: {
files: [file]
}
}) =>
uploadFileMutation({ variables: { file } }).then(() => {
console.log("file Uploade",file)
})
const onChangeHandle=(e)=>{
uploadFile({ variables: { file:e.target.files[0] } })
}
return <input type="file" required onChange={onChangeHandle} />
}

export default UploadFile

Competenze consigliate

Le migliori proposte per questo concorso

Visualizza altre proposte

Bacheca pubblica per chiarimenti

Nessun messaggio.

Come iniziare a usare i concorsi

  • Pubblica il tuo concorso

    Pubblica il tuo concorso Con facilità e in pochi istanti

  • Ottieni tante proposte

    Ottieni una Miriade di Proposte Da tutto il mondo

  • Seleziona la proposta migliore

    Seleziona la proposta migliore Scarica i file - Facile!

Pubblica subito un concorso o unisciti a noi oggi stesso!