dorche
01/26/2023, 12:33 PMtype Query {
games: [Games!]!
}
This results in a Response adapter with the following fromJson code
public override fun fromJson(reader: JsonReader, customScalarAdapters: CustomScalarAdapters): GetGamesQuery.Data {
var _games: List<GetGamesQuery.AllAccount>? = null
while(true) {
when (reader.selectName(RESPONSE_NAMES)) {
0 -> _games = Games.obj().list().fromJson(reader, customScalarAdapters)
else -> break
}
}
return GetGamesQuery.Data(
games = _games!!
)
}
But when my server encounters a “GraphQL” when running this query, the response that it sends down fails to parse, details in 🧵dorche
01/26/2023, 12:36 PM{
"errors": [
{
"message": "some-message-string",
"extensions": {
"type": "important_error_type_business_logic"
}
}
],
"data": {}
}
Which then fails the parsing, I assume because of that force unwrap in the Adapterdorche
01/26/2023, 12:37 PM{
"errors": [
{
"message": "some-message-string",
"extensions": {
"type": "important_error_type_business_logic"
}
}
],
"data": {
"games": []
}
}
Parsing works as expected.
Is this a bug on the server side? Is there anyway I could get around it on the Kotlin side?bod
01/26/2023, 1:11 PMgames
in your case), if it can't be resolved due to an error, then the whole object containing it will be null
, if that's not possible because it's itself non nullable, then its parent will, and so on, recursively, until we reach data
which is nullable.
In your case, games
is not nullable, so "data": {}
is invalid. Its parent, data
, should be null
instead.bod
01/26/2023, 1:13 PMdorche
01/26/2023, 1:13 PM{
"errors": [
{
"message": "some-message-string",
"extensions": {
"type": "important_error_type_business_logic"
}
}
],
"data": null
}
in such cases?bod
01/26/2023, 1:13 PMbod
01/26/2023, 1:15 PM"data"
at all should also work