Skip to content

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

new ApolloServer({ schema, context, uploads: false })
app.use(graphqlUploadExpress({ maxFileSize: 10000, maxFiles: 10 }))

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

My mutation looks like:

@Mutation(() => ReturnType)
  @Ctx() ctx: Context,
  @Arg('data', { description: 'File Upload' }) data: MyInputType,
): Promise<ReturnType> {
  return functionWithMagic({ ctx, data })

and my InputType like:

import { FileUpload, GraphQLUpload } from 'graphql-upload'

@InputType({ description: 'Upload data input' })
export class MyInputType {
  @Field(() => GraphQLUpload)
  file: FileUpload


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.