Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nasty misleading bug: Cannot return null for non-nullable field #2877

Closed
3 tasks done
mschipperheyn opened this issue Jun 18, 2019 · 2 comments
Closed
3 tasks done

Nasty misleading bug: Cannot return null for non-nullable field #2877

mschipperheyn opened this issue Jun 18, 2019 · 2 comments

Comments

@mschipperheyn
Copy link

This bug report should include:

  • [o ] A short, but descriptive title. The title doesn't need "Apollo" in it.
  • The package name and version of Apollo showing the problem.
  • [0] If applicable, the last version of Apollo where the problem did not occur.
  • The expected behavior.
  • 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

@timcosta
Copy link

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

@mschipperheyn
Copy link
Author

So, yeah, this is definitely a graphql bug. I reported it there: graphql/graphql-js#1989

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants