Skip to content

Commit c589e2e

Browse files
committed
Clarity for nullability and error handling
1 parent 6c21794 commit c589e2e

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

spec/Section 6 -- Execution.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -325,24 +325,28 @@ A correct executor must generate the following result for that selection set:
325325
```
326326

327327

328-
### Error handling
328+
### Nullability
329329

330-
If an error occurs when resolving a field, it should be treated as though
331-
the field returned null, and an error must be added to the "errors" list
332-
in the response.
330+
If the result of resolving a field is `null` (either because the function to
331+
resolve the field returned `null` or because an error occurred), and that
332+
field is of a `Non-Null` type, then a field error is thrown.
333333

334+
If the field was `null` because of an error which has already been added to the
335+
`"errors"` list in the response, the `"errors"` list must not be
336+
further affected.
334337

335-
### Nullability
338+
If the field resolve function returned `null`, the resulting field error must be
339+
added to the `"errors"` list in the response.
336340

337-
If the result of resolving a field is null (either because the function to
338-
resolve the field returned null or because an error occurred), and that
339-
field is marked as being non-null in the type system, then the result
340-
of evaluating the entire field set that contains this field is now
341-
null.
342341

343-
If the field was null because of an error, then the error has already been
344-
logged, and the "errors" list in the response must not be affected.
342+
### Error handling
343+
344+
If an error occurs when resolving a field, it should be treated as though
345+
the field returned `null`, and an error must be added to the `"errors"` list
346+
in the response.
347+
348+
However, if the type of that field is of a `Non-Null` type, since the field
349+
cannot be `null` the error is propogated to be dealt with by the parent field.
345350

346-
If the field resolution function returned null, and the field was non-null,
347-
then no error has been logged, so an appropriate error must be added to
348-
the "errors" list.
351+
If all fields from the root of the request to the source of the error return
352+
`Non-Null` types, then the `"data"` entry in the response should be `null`.

0 commit comments

Comments
 (0)