My code is correct, but I don’t know what’s happening, I need to upload it with graphQL but I can’t, my resolver code looks like this:
`import { Resolver, Query, Mutation, Arg } from "type-graphql";
import { GraphQLUpload, FileUpload } from "graphql-upload-ts";
@Resolver()
export class CategoryResolver {
@Mutation(() => String)
async uploadImage(@Arg("file", () => GraphQLUpload) file: FileUpload) {
console.log({ file });
return "message";
}
}`
I already changed the content-type of my apollo server sandbox to multipart/form-data and it gives this error: "POST body missing, invalid Content-Type, or JSON object has no keys." and when I change to application/json this error occurs: "Unexpected token ‘<‘, "<!DOCTYPE "… is not valid JSON" I know that the request has to be made in the multipart/form-data format. I’m adding all the fields correctly, I don’t know what’s happening, the versions are: "@apollo/server": "^4.9.5", "graphql-upload-ts": "^2.1.0", "type- graphql": "2.0.0-beta.1"
New contributor