从 Postman 中的 GraphQL 查询中获取数据时异常 (/getAccidentsForDriver) : null"



我使用的是Spring MVC、Hibernate和GraphQL。

我有两个实体类:DriverAccidentHistory

public class Driver implements java.io.Serializable {
private int personId;
private Set<AccidentHistory> accidentHistories = new HashSet<AccidentHistory>(0);
//Rest of the class
public class AccidentHistory implements java.io.Serializable {
private Integer id;
private Driver driver;
//Rest of the class

我想为Driver的ID返回所有AccidentHistory,但我无法让它为我的生命工作,我得到的只是告诉我几乎没有的例外。

这是HQL:

"FROM AccidentHistory WHERE driver.personId = :id"

这是我的GraphQL查询:

query {
getAccidentsForDriver(id: 1) {
id
}
}

为什么会出现这种异常情况?

在另一台计算机上运行相同的代码后,我们发现我笔记本电脑上的项目由于某种奇怪的原因没有构建。查询是正确的,总体上没有问题。

我只想补充一下,你需要在*.graphqls:中使用这一行

getAccidentsForDriver(id: Int!): [AccidentHistory]

相关内容

  • 没有找到相关文章

最新更新