Skip to content

Commit 678fd10

Browse files
authored
[📚 docs] Add a truth table for error handling (#6100)
* Add a truth table * hopefully more readable * try to format better
1 parent 62a0339 commit 678fd10

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/source/essentials/errors.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ title: Error handling
44

55
<Note>
66

7-
Starting with version 4.0.0, Apollo Kotlin offers a way to handle errors automatically at parsing time. Fields that are nullable only for error purposes can also be generated as non-null in Kotlin. Read ["handling nullability"](../advanced/nullability) for more details.
7+
Starting with version 4.0.0, Apollo Kotlin offers a way to handle errors automatically at parsing time. Fields that are nullable only for error purposes can also be generated as non-null in Kotlin. You can read more about it in the ["handling nullability" page](../advanced/nullability).
88

99
</Note>
1010

1111
## `ApolloResponse`
1212

13+
`ApolloResponse` contains three important fields:
14+
* `exception` contains the fetch error if any.
15+
* `errors` contains the GraphQL errors if any.
16+
* `data` contains the returned (potentially partial) data if any.
17+
1318
Use `ApolloResponse.data` to check if the server returned data:
1419

1520
```kotlin
@@ -137,3 +142,16 @@ For an example, it is possible for a person to not have a starship:
137142
```
138143

139144
In that case, `starship` is a true null and not an error.
145+
146+
## Truth table
147+
148+
| exception | data | errors | meaning |
149+
|-----------|-----------|-----------|-----------------------------------------------------------------------------|
150+
| `null` | `null` | `null` | Non-compliant server, if `data` is null, there should be at least one error |
151+
| `null` | `null` | `present` | A GraphQL request error happened or a Graph field error bubbled up. |
152+
| `null` | `present` | `null` | Complete data was received. |
153+
| `null` | `present` | `present` | Partial data was received alongside field error(s). |
154+
| `present` | `null` | `null` | A fetch error happened. |
155+
| `present` | `null` | `present` | 🙅‍♂️ impossible. |
156+
| `present` | `present` | `null` | 🙅‍♂️ impossible. |
157+
| `present` | `present` | `present` | 🙅‍♂️ impossible. |

0 commit comments

Comments
 (0)