使用 GraphQL NestJS 上传

Sof*_* A. 1 upload node.js graphql nestjs

有人有如何使用 GraphQl 在 NestJs 中上传文件的示例吗?

我可以通过控制器使用给定的示例上传

https://github.com/nestjs/nest/issues/262#issuecomment-366098589

但我找不到任何全面的文档如何在 NestJS 中使用 GrahpQL 上传

wil*_*ire 5

Apollo Server 2.0 现在应该能够做到这一点(打包在 Nest 中),尽管我需要安装graphql-upload和导入GraphQLUpload,因为我找不到Upload类型:

@Mutation(() => Image, { nullable: true })
async addImage(@Args({ name: 'image', type: () => GraphQLUpload }) image) {
  // Do stuff with image...
}
Run Code Online (Sandbox Code Playgroud)