'Spring-Boot GraphQL QueryResolver is not called

When I call a query in graphiQL i get the following response

{
  "errors": [
    {
      "message": "The field at path '/customers' was declared as a non null type, but the code involved in retrieving data has wrongly returned a null value.  The graphql specification requires that the parent field be set to null, or if that is non nullable that it bubble up null to its parent and so on. The non-nullable type is '[Customer!]' within parent type 'Query'",
      "path": [
        "customers"
      ],
      "extensions": {
        "classification": "NullValueInNonNullableField"
      }
    }
  ],
  "data": null
}

Query:

    query{
     customers {
      id
      email
     }

}

The Problem is that my GraphQLQuery Resolver dont get called. I did a Breakpoint and the Application doesnt break there.

GraphQLQueryResolver:

@RequiredArgsConstructor
@Component
public class Query implements GraphQLQueryResolver {

    private final CustomerRepository customerRepository;
    
    public Flux<Customer> customers() {
        return customerRepository.findAll();
    }
    
}

query.graphqls:

type Query{
    customers: [Customer!]!
}

customer.graphqls:

type Customer {
    id: ID!,
    email: String!
}


Solution 1:[1]

This is expected as GraphQLQueryResolver is a type from the graphql-java-kickstart project. Spring for GraphQL is not related at all to this project.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brian Clozel