Closed antunespedro80 closed 2 years ago
What the Upload
scalar promise resolves is fully documented in the readme:
https://github.com/jaydenseric/graphql-upload/tree/v13.0.0#type-fileupload
However, on index.d.ts, you show that interface FileUpload consists of:
I don't show that; the @types/graphql-upload
package is not maintained by me. Feel free to PR Definitely Typed to update those types if any are wrong.
I have an exception like "file.createReadStream is not a function".
Do you have a runtime exception, or are you talking about a TypeScript type check error message?
I don't show that; the @types/graphql-upload package is not maintained by me. Feel free to PR Definitely Typed to update those types if any are wrong.
Yeah, you're right, my bad...
Do you have a runtime exception, or are you talking about a TypeScript type check error message?
Both
If you run npm ls graphql-upload
within your project, do you see multiple versions of graphql-upload
installed?
Nop, only graphql-upload@13.0.0
If you console.log
what the awaited Upload
scalar promise resolves in the resolvers, what do you see?
It looks like it is working… you're supposed to await the upload, then you can do .createReadStream()
on what it resolves.
Yeah, but when I try to do .createReadStream()
, triggers the exception file.createReadStream is not a function
That is really strange. Maybe you are not using the GraphQLUpload
scalar exported from graphql-upload
, but another one?
If you reach into node_modules
, and put a console.log
just before these lines, do both log when you run into the problem?
Yes, I can console.log
both lines, 278 and 81
I just updated the example API to use the latest graphql
and graphql-upload
versions, and everything works fine:
https://github.com/jaydenseric/apollo-upload-examples/tree/master/api
There is something funky going on in your project.
Closing because this problem couldn't be reproduced, so there is nothing I can action from here. If you manage to put together a minimal project (vanilla Node.js, no TypeScript or other build tools) that demonstrates a specific bug in this graphql-upload
package we can reopen and investigate further.
Ok, thanks for the help, I will try do my best to replicate this. I'm using this with nestjs, I don't know if it is the problem or not... But, no problem, I will figure this out.
Thanks a lot!
Hi! I was reading your documentation and there, you show that FileUpload interface is an interface with:
So, what happens ? When I try to do a stream like
const stream = file.createReadStream()
, I have an exception like "file.createReadStream is not a function".package.json graphql-upload@^13.0.0 @types/graphql-upload@^8.0.7