jaydenseric / graphql-upload

Middleware and a scalar Upload 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 132 forks source link

`parseValue` expects get an instance of `Upload` value #197

Closed ARHariri closed 4 years ago

ARHariri commented 4 years ago

Hi there. I cannot upload a file as I get "Upload value invalid" error, unless I override parseValue function. As I see, there is a condition in parseValue function (in the GraphQLUpload.js file) that expects to get an instance of Upload value. I think this condition should be changed to something like this value instanceof Blob to resolve the error (Check the value to be an instance of Blob instead of Upload).

p.s.: It seems this condition added to resolve this issue.

jaydenseric commented 4 years ago

Why would you expect it to not be an Upload instance? Perhaps you are importing the GraphQLUpload scalar from a different graphql-upload version than the processRequest function is from. You can check by running npm ls graphql-upload - there should only be one version in your node_modules.

ARHariri commented 4 years ago

I use apollo-server-express that uses graphql-upload v8.1.0 as a dependency and I installed the latest version (v10.0.0) to define Upload scalar (apollo-server handles uploading files (with graphql-upload) but I should create Upload scalar manually because I use nexus to create GraphQL schemas). So there are two versions of graphql-upload package inevitably.

jaydenseric commented 4 years ago

Closing because the problem is not an issue with graphql-upload. There are existing issues you can find in the Apollo repos about graphql-upload being outdated in their dependencies, and the various workarounds available to manually upgrade.