tim
06/09/2020, 6:08 PMfun testQuery(id: Id): DataFetcherResult<String> {
return DataFetcherResult
.newResult<String>()
.error(Failure.App.Unknown)
.build()
}
But bc String is non nullable, I get a 'NullValueInNonNullableField' error when this result is returned to my graphql client. If I put .data(null)
into the builder pattern, then I get an error about String being non nullable and then I get a slightly different error.
I assume that if an error occurs, returning null is correct, but I'd prefer to not have nullable return values if I can avoid it?Dariusz Kuc
06/09/2020, 6:15 PMI assume that if an error occurs, returning null is correct, but I’d prefer to not have nullable return values if I can avoid it?unfortunately this breaks the schema safety
Dariusz Kuc
06/09/2020, 6:16 PMShane Myrick
06/09/2020, 6:17 PMKotlinDataFetcherExceptionHandler
But as mentioned above, if you return a DataFetcherResult
it should fulfill the schema contract and return both data and errors, even if that data is nullShane Myrick
06/09/2020, 6:19 PMDataFetcherResults
can be used at any level of the schema so you may have a field 10 levels deep in the schema and we need to know how to handle that result. Is just this field an error and should be null or should we throw an exception and fail the entire requesttim
06/09/2020, 6:40 PM