moleculerjs / moleculer-apollo-server

:rocket: Apollo GraphQL server for Moleculer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File upload issue

dg92 opened this issue · comments

I am using https://altair.sirmuel.design (graphql IDE) to upload
this is how my action looks like

uploadFile: { graphql: { mutation: "uploadFile(file: Upload!, entityId: String!): Media", fileUploadArg: "file", }, async handler(ctx) { const fileChunks = []; for await (const chunk of ctx.params) { fileChunks.push(chunk); } const fileContents = Buffer.concat(fileChunks); // Do something with file contents return ctx.meta.$fileInfo; } }

Issue - i don't see readablestream in my ctx.params and my ctx.meta is an empty object, Error is object is not iterable , however, i can see that my ctx.params contains file obj with filename, mimetype, encoding that's it

There's not really enough information here for me to help you out. What is the error? How is your Media type defined? You're returning ctx.meta.$fileInfo which has very specific properties -- does that conform to your Media type?

@shawnmcknight I am sry i edited it but did not save it, Media is just a datatype that has id(UUID) and publicURL(string) and i added the issue in the starting comment. For me the issue is i am missing the stream from the file Obj.

@shawnmcknight I am sry i edited it but did not save it, Media is just a datatype that has id(UUID) and publicURL(string) and i added the issue in the starting comment. For me the issue is i am missing the stream from the file Obj.

What version of moleculer-apollo-server are you running? The README for uploads (and the format you are using) is only relevant for version >= 0.3.0.

@shawnmcknight yeah, I just checked I am using 0.2.0 version, thanks, i'm closing this for now.