Description
The return type for a non-nullable list is inconsistent with schema when a field error is present. This makes guaranteeing the type via the non-nullable contract inconsistent.
Given the following schema, it is my understanding that I should always receive an array typed object (not a null).
type Image {
url: String!
}
type Product {
images: [Image]!
}
images = [] // valid
images = null // invalid
images = [null] // valid
However, if the resolver for images encounters an error, the returned type is Null
.
Recieved
{
"errors": [
{
"message": "'foozles' is not a supported image transformation.",
"path": [
"listing",
"images"
],
"extensions": {
"code": "CLIENT_ERROR"
}
}
],
"data": {
"listing": {
"images": null
}
}
}
This is explicitly tested for in execution/tests/lists-test.js, but seems inconsistent with the declared type contract.
Expected
{
"errors": [
{
"message": "'foozles' is not a supported image transformation.",
"path": [
"listing",
"images"
],
"extensions": {
"code": "CLIENT_ERROR"
}
}
],
"data": {
"listing": {
"images": []
}
}
}
Non-nullable types (for certain fields) allows a higher level of type safety and is especially useful while handling partial failures.
Is this behavior intended? Is there a way to support the behavior I would have expected given the current type system and error handling behavior? There is a reference to handling this in the parent field in the spec, but I'm unsure that would be consistently implemented in my resolver or parent resolver?