简体   繁体   中英

Exception while fetching data (/getAccidentsForDriver) : null" from a GraphQL query in Postman

I'm using Spring MVC, with Hibernate and GraphQL.

I have 2 entity classes: Driver and AccidentHistory .

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

I want to return all the AccidentHistory for an ID of a Driver , but I cannot get it to work for the life of me and all I get is the exception which tells me close to nothing .

This is the HQL:

"FROM AccidentHistory WHERE driver.personId = :id"

This is my GraphQL query:

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

Why does this exception happen?

After running the same code on another computer, we figured out that the project on my laptop wasn't building for some weird ass reason. The query is correct and there were no problems in general.

I would just add that you need this line in your *.graphqls:

getAccidentsForDriver(id: Int!): [AccidentHistory]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM