Why does a GraphQL query return null?

I have an graphql/apollo-server/graphql-yoga endpoint. This endpoint exposes data returned from a database (or a REST endpoint or some other service).

I know my data source is returning the correct data -- if I log the result of the call to the data source inside my resolver, I can see the data being returned. However, my GraphQL field(s) always resolve to null.

If I make the field non-null, I see the following error inside the errors array in the response:
Cannot return null for non-nullable field

Why is GraphQL not returning the data?

Write your answer...

Never miss a post from Snehal Kumar, when you sign up for Ednsquare.