-
Notifications
You must be signed in to change notification settings - Fork 221
Open
Description
If a field has an Option as it's value, eg:
val FieldWithOption = ObjectType[Unit, Option[String]](
"Option",
fields[Unit, Option[String]](Field("hello", StringType, resolve = _.value.getOrElse("Hello, world!"))))
val QueryTypeThatFails = ObjectType("Query", fields[Unit, Unit](
Field("hello", FieldWithOption, resolve = _ => None)
))
When this field is queried in the Some case it works, but in the None case it fails at runtime, when queried, with:
{
"data" : null,
"errors" : [
{
"message" : "Cannot return null for non-nullable type (line 1, column 3):\n{ hello { hello } }\n ^",
"path" : [
"hello"
],
"locations" : [
{
"line" : 1,
"column" : 3
}
]
}
]
}
The complete example can be found here https://github.com/anderslm/sangria-option/
I'm guessing this is why it happens:
| case None => |
Metadata
Metadata
Assignees
Labels
No labels