I am using apollo client
react UI
“@apollo/client”: “^3.8.1”,
“apollo-link”: “^1.2.14”,
“apollo-upload-client”: “^18.0.1”
**NodeJs **
“apollo-server-express”: “^2.21.1”
File is not getting uploaded Please help import createUploadLink from “apollo-upload-client/createUploadLink.mjs”
const httpLink = createUploadLink({
uri: ""
});
const link = from([errorLink, httpLink, new HttpLink({ uri:""})]);
export const UPLOAD_FILE = gql `
mutation ($file: Upload!) {
uploadCsv(file: $file) {
message
}
}`
const [uploadFile, {data: uploadedData, loading: uploading, error: uploaderror}] =
useMutation(UPLOAD_File)
const result = await uploadFile({
fetchPolicy: "network-only",
variables: {
file
}
});
Request Payload:
operations: {"variables":{"file":null},"query":"mutation ($file: Upload!) {n
upload(file: $file) {n messagen __typenamen }n}"} map: {"1":
["variables.file"]} 1: (binary)
Reponse preview:
BadRequestError: request size did not match content length
at IncomingMessage.onEnd (node_modulesraw-bodyindex.js:277:12)
at IncomingMessage.emit (node:events:524:35)
at IncomingMessage.emit (node:domain:489:12)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
us!!