Upload request have all time status 'pending' in network tab
Juliaxddd opened this issue · 3 comments
Juliaxddd commented
jaydenseric commented
In the GraphQL API resolvers, are you using the file upload streams?
kengres commented
@Juliaxddd
This is happening on the server. I didn't understand the issue myself 🤔 , but I think it has all to do with the file
sent to the server being a Promise with a createReadStream
function.
I worked around it by simulating a stream in NodeJs and it worked. Another alternative is to upload the file to a server somewhere, but if you're like me, you want to test the file before that.
Hence 🚀 :
async function logChunks(readable) {
for await (const chunk of readable) {
console.log(chunk);
}
}
// And in your mutation:
resolve: async (_, { file }, ctxt) => {
try {
const { createReadStream } = await file;
await logChunks(createReadStream());
return 'success'; // or whatever you want to return
} catch (error: any) {
throw error.message;
}
}
jaydenseric commented
Closing due a lack of response; given other people don't seem to have the the same issue it's likely not due to something being wrong with apollo-upload-client
. If that assumption is incorrect we can reopen and investigate further.