Apollo-server: Nasty misleading bug: Cannot return null for non-nullable field

Created on 18 Jun 2019  路  2Comments  路  Source: apollographql/apollo-server

This bug report should include:

  • [o ] A short, but descriptive title. The title doesn't need "Apollo" in it.
  • [x] The package name and version of Apollo showing the problem.
  • [0] If applicable, the last version of Apollo where the problem did _not_ occur.
  • [x] The expected behavior.
  • [x] The actual behavior.
  • [o ] A simple, runnable reproduction!

So, TDLR. GraphQLError: Cannot return null for non-nullable field is thrown with a field reference that is not the correct nulled field.

In my case, I spent hours and hours debugging GraphQLError: Cannot return null for non-nullable field Social__User.id.. And the id was there! Turns out, I returned a null value on another non nullable field on that type and either graphql or apollo indicates the wrong frigging field on the error message!

Apollo client: 2.6.2
Apollo server express 2.6.2
graphql 14.3.1
graphql-tools 4.0.4

Most helpful comment

So, yeah, this is definitely a graphql bug. I reported it there: https://github.com/graphql/graphql-js/issues/1989

All 2 comments

We're also seeing this issue. It seems to happen when we dont try/catch something in an async resolver function that then throws.

So, yeah, this is definitely a graphql bug. I reported it there: https://github.com/graphql/graphql-js/issues/1989

Was this page helpful?
0 / 5 - 0 ratings