如果我使用graphql-java,我不知道如何上传文件,有人可以给我演示吗?我将不胜感激!
参考:https : //github.com/graphql-java-kickstart/graphql-java-tools/issues/240
我在springboot中通过使用graphql-java-kickstart graphql-java-tools尝试了一下,但是没有用
@Component
public class FilesUpload implements GraphQLMutationResolver {
public Boolean testMultiFilesUpload(List<Part> parts, DataFetchingEnvironment env) {
// get file parts from DataFetchingEnvironment, the parts parameter is not used
List<Part> attchmentParts = env.getArgument("files");
System.out.println(attchmentParts);
return true;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的架构
type Mutation {
testSingleFileUpload(file: Upload): UploadResult
}
Run Code Online (Sandbox Code Playgroud)
我希望这个解析器可以打印attchmentParts,所以我可以得到文件的一部分。