上传图像到GraphQL服务器

我正在使用react-dropzone和graphql-server-express-upload在GraphQL Apollo中上传图像。 在我的客户端文件看起来像这样: 文件在客户端

但在服务器上,当我login时,看起来像这样:

{ preview: 'blob:http://localhost:3000/c622b0bd-3f0d-4f52-91f4-7676c8534c59' } 

我正在按照graphql-server-express-upload的自述文件中的说明进行操作,但目前为止还没有成功。 如何获得完整的图像?

另一种方法是在上传之前将二进制映像转换为客户端上的BASE64,然后将图像填充为作为variablesparameter passing的GraphQLInputObjectType上的BASE64string。 在服务器上,字段可以简单地保存在数据库列中。 例如:

 const UserInputType = new GraphQLInputObjectType({ name: 'UserInput', description: 'The user of our system', fields: () => ({ username: { type: GraphQLString, description: 'Name of the user' }, image: { type: GraphQLString, description: 'Image of the user' } }) }); 

我最终使用apollo-upload-client ,效果很好!