Skip to content
Advertisement

Variable “$file” got invalid value

I try to upload a file with GraphQL. While upload, I get following error message:

Variable “$file” got invalid value { resolve: [function], reject: [function], promise: {}, file: { filename: “insung-yoon-TPvE8qPfMr0-unsplash.jpg”, mimetype: “image/jpeg”, encoding: “7bit”, createReadStream: [function createReadStream] } }; Upload value invalid.

The only solution I found, was to disable the upload at apollo-graphql and add graphql-upload

JavaScript

I already had added this setting, but the issue is still there.

My mutation looks like:

JavaScript

and my InputType like:

JavaScript

Advertisement

Answer

After a lot of searching, I finally found my issue. We are using a mono repo, and had installed two different version of file-upload in two packages. When I changed the version, at both packages on the same version and the error is gone.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement