- the request was successful,
- your request encountered an error,
- your request encountered an error but could still produce a result.
Operation Result Errors vs Throwables
Because Swift is a compiled, statically typed language, we need to be explicit about every type conversion happening in our code. To make sure developer experience doesn’t suffer, SwiftGraphQL produces a terminating error when it encounters a diviation from the schema and produces aDecodedOperationResult
in other cases.
You can read more about error handling in The Swift Programming Language.
Combined Errors
CombinedError pattern is heavily inspired by urql client. I suggest you check their documentation for any further explanations.When we use a GraphQL API there are two kinds of errors we may encounter: Network Errors and GraphQL Errors from the API. Since it’s common to encounter either of them, there’s a CombinedError class that can hold and abstract either.
It’s worth noting that an error can coexist and be returned in a successful request alongside data. This is because in GraphQL a query can have partially failed but still contain some data.