jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

Type mismatch errors internal to graphql-upload #323

Closed markgreenwood closed 2 years ago

markgreenwood commented 2 years ago

I have followed the advice elsewhere about importing correctly from graphql-upload and using the recommended settings in tsconfig.json, but I'm still getting type errors that seem to be internal to graphql-upload and its dependencies:

> tsc

node_modules/graphql-upload/processRequest.js:272:47 - error TS2345: Argument of type 'FileUploadCreateReadStreamOptions' is not assignable to parameter of type 'string'.

272             return capacitor.createReadStream(options);
                                                  ~~~~~~~

node_modules/graphql-upload/processRequest.js:332:35 - error TS2339: Property 'release' does not exist on type 'WriteStream'.

332             upload.file.capacitor.release();
                                      ~~~~~~~

Found 2 errors in the same file, starting at: node_modules/graphql-upload/processRequest.js:272
jaydenseric commented 2 years ago

Perhaps the version or types for the dependency fs-capacitor is incorrect? Also, do you have @types/node installed, at the right version?

I can't really debug the problem for you because you need to try to figure out where those types are coming from, etc. in your project.

uragecz commented 2 years ago

@jaydenseric, @markgreenwood there is a problem, that this library has in dependency of types - "@types/fs-capacitor": "*". And if you check it here , you can see it's wrong there / not updated. They don't maintain these types anymore.

jaydenseric commented 2 years ago

@markgreenwood The problem is likely that you incorrectly have @types/graphql-upload installed in your project, and as @uragecz pointed out those types pull in @types/fs-capacitor which are outdated:

https://unpkg.com/browse/@types/graphql-upload@8.0.11/package.json

Recent versions of graphql-upload have built in types via TypeScript JSDoc comments, so you should uninstall @types/graphql-upload from your project. If it's not you that installed it, but one of your dependencies, you can track down where it's coming from by running npm ls @types/graphql-upload.

markgreenwood commented 2 years ago

@markgreenwood The problem is likely that you incorrectly have @types/graphql-upload installed in your project, and as @uragecz pointed out those types pull in @types/fs-capacitor which are outdated:

https://unpkg.com/browse/@types/graphql-upload@8.0.11/package.json

Recent versions of graphql-upload have built in types via TypeScript JSDoc comments, so you should uninstall @types/graphql-upload from your project. If it's not you that installed it, but one of your dependencies, you can track down where it's coming from by running npm ls @types/graphql-upload.

Did not have @types/graphql-upload installed, but I did finally find an old deeply buried import {...} from "graphql-upload" that I had missed. Correcting that fixed it.