-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
https://spec.graphql.org/draft/#sec-Errors-and-Non-Nullability describes that any error in a non-null field should be propagated to its parent field, destroying the parent. This applies recursively to further ancestor fields, and across arrays with non-null members (if one member is null, the whole array should be destroyed).
Thus all ancestors are destroyed for a failure of any one of their descendants, if there is a chain of non-null fields going up from such descendants.
This destructive behavior is reminiscent of first-order logic, where one contradiction (being able to infer false) renders the whole system useless (you can infer anything).
Such behavior is brittle and I consider it harmful for real-world data integration scenarios, which I think is a major use case for GraphQL. When building a Knowledge Graph, you may have a field that's non-null and is valid in 99.99% of cases, but due to data quality problems there's almost always a tiny percentage of missing or malformed values that will cause such destruction.
This destructive behavior is implemented in some key software, and that harms our development efforts in the Ontotext Platform (which implements GraphQL over RDF Knowledge Graphs), see https://www.apollographql.com/docs/react/data/error-handling/
- Both Apollo Client and Apollo Federation examine every GraphQL endpoint response and perform such destruction (mangle the response)
- Furthermore, they propagate the "error" report upward and report the same problem at each ancestor level
- At least the Client has a flag/mode to not mangle the response; Federation doesn't have such flag
https://www.apollographql.com/blog/using-nullability-in-graphql-2254f84c4ed7 by @stubailo explains related issues in detail. In particular "For output fields, removing non-null from a field is a breaking change".
All this means that you can never use non-null, except for fields such as ID without which you can't even find the object. Which weakens the GraphQL schema, eg leaves fewer clues for data entry UIs.
(Note: #259 is a bit related)