我正在使用graphql-spring-boot来服务来自我的spring-boot项目的graphql查询。现在,我正在将graphql方案类型定义与我的spring entites进行匹配。无论出于什么原因,我都会收到以下错误:
Caused by: com.coxautodev.graphql.tools.SchemaClassScannerError: Unable to match type definition (ListType{type=TypeName{name='HomestayInfo'}}) with java type (class ninja.familyhomestay.domain.HomestayInfo): Java class is not a List or generic type information was lost: class ninja.familyhomestay.domain.HomestayInfo
at com.coxautodev.graphql.tools.TypeClassMatcher.error(TypeClassMatcher.kt:19)
at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:79)
at com.coxautodev.graphql.tools.TypeClassMatcher.match(TypeClassMatcher.kt:25)下面是我为HomestayInfo定义的graphql模式
type HomestayInfo{
homestayName: String
homestayShortDescription: String
homestayDescription: String
address: Address
rooms: [Room]
houseImages: [HouseImage]
pets: [Pet]
}和对应的kotlin实体:
@Entity
@Table(name = "homestay_info")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "homestay_info")
data class HomestayInfo(
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
var id: Long? = null,
@Column(name = "homestay_name")
var homestayName: String? = null,
@Column(name = "homestay_short_description")
var homestayShortDescription: String? = null,
@Column(name = "homestay_description")
var homestayDescription: String? = null,
@OneToOne
@JoinColumn(name = "address_id")
var address:Address?=null,
@OneToMany(mappedBy = "homestayInfo", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
var rooms: MutableSet<Room> = HashSet(),
@OneToMany(mappedBy = "homestayInfo", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
var houseImages: MutableSet<HouseImage> = HashSet(),
@OneToMany(mappedBy = "homestayInfo", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
var pets: MutableSet<Pet> = HashSet()
) : Serializable我看不出映射有什么问题。有什么想法吗?
发布于 2018-10-16 06:57:43
将标量日期添加到schema.graphqls文件的顶部应该可以做到这一点!因此,您的文件将如下所示:
scalar Date
schema { // not sure if your file has this, but mine does
query: Query
}
type HomestayInfo{
...https://stackoverflow.com/questions/51679341
复制相似问题