java - 使用graphql java kickstart的spring boot中的联合类型错误
问题描述
我在 graphql 中的 union 有问题,我尝试用 graphql 制作教程,但我遇到了一个错误
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
com.coxautodev.graphql.tools.UnionTypeResolver.<init>(DictionaryTypeResolver.kt:41)
The following method did not exist:
'java.lang.String graphql.schema.GraphQLOutputType.getName()'
这是我在 graphqls 中定义的联合
type Talk {
id : ID!
title : String
description : String
speakers : [ Speaker ]
}
type Speaker {
id : ID!
name : String
twitter : String
}
union All = Speaker | Talk
type Query {
allAll : [All]
}
这是我的方法 allAll 的解析器
@RequiredArgsConstructor
public class MemberQueryResolver implements GraphQLQueryResolver {
private final SpeakerService speakerService;
private final TalkService talkService;
public List<Object> allAll() {
var list = new ArrayList<Object>();
list.addAll(speakerService.findAll());
list.addAll(talkService.findAll());
return list;
}
}
这是我的配置模式方法
private GraphQLSchema buildSchema(TalkService talkService, AttendeeService attendeeService,
SpeakerService speakerService) {
return SchemaParser
.newParser()
.file("graphql/schema.graphqls")
.resolvers(
new MemberQueryResolver(speakerService, talkService)
)
.build()
.makeExecutableSchema();
}
当我删除解析器时,我收到错误,allAll 映射的方法不存在,但是当我使用此方法注册解析器时,spring 服务器崩溃并出现上述错误。有没有人尝试用 java kickstart 做联合类型并且可以告诉我问题或我的错误?
解决方案
推荐阅读
- list - 如何在haskell的树中列出所有可能的单词
- java - 解析电子邮件返回 com.sun.mail.util.MailConnectException 异常
- c - 在 C 中何时分配和取消分配静态和动态内存?
- javascript - 如何从包含多行的Javascript字符串中截断最后一个换行符
- python - 如何将 Figure 对象转换为具有 RGBA 值的 Numpy 数组?
- elasticsearch - 如何让 Elasticsearch 突出显示 search_as_you_type 字段中的部分单词?
- microsoft-teams - 尝试在 MS Teams 上上传自定义应用程序时出错
- android - Android Studio - CPU profiler .trace = "CPU 使用详情不可用"
- cdap - 如何通过 CDAP 管道的文件提供运行时参数/参数值
- sql - SQL Select语句如何返回表情符号