I am working on a graphql issue where I am getting following error for the request
{
customer(id: "5ed6092b-6924-4d31-92d0-b77d4d777b47") {
id
firstName
lastName
carsInterested
}
}
"message": "Validation error of type SubSelectionRequired: Sub selection required for type null of field carsInterested @ 'customer/carsInterested'",
Below is my schema
type Customer {
id: ID!
firstName: String!
lastName: String!
# list of cars that the customer is interested in
carsInterested: [Car!]
}
type Query {
# return 'Customer'
customer(id: ID!): Customer
}
I do have a CustomerResolver with function carsInterested in it.It looks as follows
@Component
public class CustomerResolver implements GraphQLResolver<Customer> {
private final CarRepository carRepo;
public CustomerResolver(CarRepository carRepo) {this.carRepo = carRepo;}
public List<Car> carsInterested(Customer customer) {
return carRepo.getCarsInterested(customer.getId());
}
}
When I query for customer without 'carsInterested', it works properly. Any idea why I am getting this error?
Thanks