Errors and null propagation

GraphQL Course · lesson 8 of 14 · 4 min read

GraphQL returns 200 with an errors array - and a non-null failure can wipe out its parent.

Open this lesson in the learning hub

Key points

  • A GraphQL response is usually HTTP 200 even when fields failed - check the errors array, not the status.
  • Partial success is normal: data may hold some fields while errors explains the rest.
  • If a resolver for a non-null field fails, null cannot be placed there - so the error propagates to the parent.
  • That can null out a whole object because one deep required field failed.
  • So mark a field non-null only when it genuinely can never be absent.

Every ! is a promise that failing to keep will null out the parent - use it sparingly.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the GraphQL Course course, and every lesson in it is listed on the GraphQL Course contents page.