Tuesday, February 15, 2022

Error executing query (ValidationError): Validation error of type SubSelectionNotAllowed: Sub selection not allowed on leaf type null of field

 Hello, While working with graphql query/mutation we will get some common exception, due to careless mistake, here we will see kind of issue, I got this exception while calling query resolver.


Query failed to validate : 'query getBookingTypes($email: String!) { getBookingTypes(email: $email) { BookingType } }' 


Error executing query (ValidationError): Validation error of type SubSelectionNotAllowed: Sub selection not allowed on leaf type null of field getBookingTypes @ 'getBookingTypes' 


This call is about to retrieve type of booking  method from QueryResolver which returns list of Object. 

We have checked the return type in both schema file and implementation and other check also looks good.

Below query and enum object,

Query:




enum BookingType{
ADMIN
USER
GUEST
}

Then we found that,  in output data field we have mentioned as BookingType. Here BookingType is ENUM.
So we have changed the query like below, 

After this changes we got output like below,
    ADMIN
USER
GUEST

Issue fixed!.

No comments:

Post a Comment