jaydenseric/apollo-upload-client

Upload request have all time status 'pending' in network tab

Juliaxddd opened this issue · 3 comments

Hey, i try to implement upload feature to my app, i tested uploading files with Altair client - all working.
For now when i try to send request in network tab i see all time "(pending)".

image

image

image

image

In the GraphQL API resolvers, are you using the file upload streams?

@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;
  }
}

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.