Errors and null propagation
GraphQL returns 200 with an errors array - and a non-null failure can wipe out its parent.
Open this lesson in the learning hubKey points
- A GraphQL response is usually HTTP 200 even when fields failed - check the
errorsarray, not the status. - Partial success is normal:
datamay hold some fields whileerrorsexplains 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.