benawad / type-graphql-series

Typescript GraphQL Server built with TypeGraphQL
326 stars 129 forks source link

Upload value invalid. #23

Closed dewaleolaoye closed 3 years ago

dewaleolaoye commented 4 years ago

Thanks, Ben for the series, please help I'm getting this error

{
  "message": "Variable \"$picture\" got invalid value {}; 
              Expected type Upload. Upload value invalid.",
}

This is how I pass the values on Postman I've checked the docs over and over

{
   "query": "mutation UploadFile($picture: Upload!) {uploadFile(picture: $picture) }", 
   "variables": {"picture": null}
}

and for the map field this is what I pass

{ 
   map:  ["variables.picture"] 
}

and then the file field which is 0

   0: uploaded_file
benawad commented 4 years ago

that looks correct, I'm not sure why it doesn't work

you could try curl https://github.com/jaydenseric/graphql-multipart-request-spec#curl-request-1 or using https://github.com/jaydenseric/apollo-upload-client

dewaleolaoye commented 4 years ago

Thanks, Ben, I will check it out

canali83 commented 4 years ago

having same error. why we use import { GraphQLUpload } from "graphql-upload" instead of import { GraphQLUpload } from "apollo-server-express";

i tried to change but @Arg("photo", () => GraphQLUpload) line give the following error

No overload matches this call. Overload 1 of 2, '(name: string, options?: Options | undefined): ParameterDecorator', gave the following error. Type '() => GraphQLScalarType | undefined' has no properties in common with type 'Options'. Overload 2 of 2, '(name: string, returnTypeFunc: ReturnTypeFunc, options?: Options | undefined): ParameterDecorator', gave the following error. Type 'GraphQLScalarType | undefined' is not assignable to type 'ReturnTypeFuncValue'. Type 'undefined' is not assignable to type 'ReturnTypeFuncValue'.ts(2769) types.d.ts(10, 38): The expected type comes from the return type of this signature. Photo.ts(13, 19): Did you mean to mark this function as 'async'?

benawad commented 4 years ago

I think you just want import { GraphQLUpload } from "graphql-upload"

rafinskipg commented 3 years ago

I am experiencing the same issue @benawad . I am sending the file from the client side using https://github.com/jaydenseric/apollo-upload-client as an Upload type. But the Upload type is not being understood by the API. I think it needs to be declared somehow

rafinskipg commented 3 years ago

Sorry, i added graphql-upload as a dependency, meanwhile apollo-server-express already includes version 8. And having both created the confusing error