need help to debug fileupload for a given mutation

  • 状态: Pending
  • 奖金: ₹5000
  • 参赛作品已收到: 1

竞赛简介

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

您还可能感兴趣的技能

此竞赛的顶尖作品

查看更多参赛作品

公共说明面板

还没有信息。

如何以竞赛开始

  • 发布您的竞赛

    发起您的竞赛 快速简单

  • 获取众多参赛作品

    获取大量参赛作品 来自世界各地

  • 悬赏最佳参赛作品

    悬赏最佳参赛作品 下载文件-简单!

立即发布竞赛 或者立即加入我们!