Martin Brehovsky
07/12/2021, 11:52 PMDariusz Kuc
07/13/2021, 1:06 AMDariusz Kuc
07/13/2021, 1:07 AMMartin Brehovsky
07/13/2021, 1:40 AMDariusz Kuc
07/13/2021, 2:05 AMDariusz Kuc
07/13/2021, 2:06 AMMartin Brehovsky
07/13/2021, 2:16 AMMartin Brehovsky
07/13/2021, 2:16 AMDariusz Kuc
07/13/2021, 2:18 AMMartin Brehovsky
07/13/2021, 2:19 AMfun failNullableCF(): CompletableFuture<Boolean?> = CompletableFuture.failedFuture(RuntimeException("failed nullable future"))
fun failNonNullableCF(): CompletableFuture<Boolean> = CompletableFuture.failedFuture(RuntimeException("failed non nullable future"))
failNullableCF
ends up with
{
"data": {
"dog": {
"failNullableCF": null
}
},
"errors": [
{
"message": "failed nullable future",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"dog",
"failNullableCF"
]
}
]
}
Martin Brehovsky
07/13/2021, 2:19 AMMartin Brehovsky
07/13/2021, 2:19 AM{
"errors": [
{
"message": "failed non nullable future",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"dog",
"failNonNullableCF"
]
}
]
}
Martin Brehovsky
07/13/2021, 2:20 AM{
dog {
failNullableCF
}
}
and the second query is
{
dog {
failNonNullableCF
}
}
Dariusz Kuc
07/13/2021, 2:21 AMMartin Brehovsky
07/13/2021, 2:21 AMDariusz Kuc
07/13/2021, 2:21 AMMartin Brehovsky
07/13/2021, 2:21 AMDariusz Kuc
07/13/2021, 2:21 AMgraphql-java
logic to see how it resolves the CF failuresDariusz Kuc
07/13/2021, 2:22 AMMartin Brehovsky
07/13/2021, 2:23 AMfun failNullableFun(): Boolean? = throw RuntimeException("failed nullable function")
fun failNonNullableFun(): Boolean = throw RuntimeException("failed non nullable function")
{
dog {
failNullableFun
}
}
returns as
{
"data": {
"dog": {
"failNullableFun": null
}
},
"errors": [
{
"message": "failed nullable function",
"locations": [
{
"line": 3,
"column": 5
}
],
"path": [
"dog",
"failNullableFun"
]
}
]
}
I would expect the query to completely failDariusz Kuc
07/13/2021, 2:23 AMDariusz Kuc
07/13/2021, 2:23 AMDariusz Kuc
07/13/2021, 2:23 AMDariusz Kuc
07/13/2021, 2:24 AMdog
)Martin Brehovsky
07/13/2021, 2:24 AMfailNullableFun
failed, it did not resolveDariusz Kuc
07/13/2021, 2:25 AMMartin Brehovsky
07/13/2021, 2:25 AMfun failNullableFun(): Boolean? = throw RuntimeException("failed nullable function")
and
fun nullableFun(): Boolean? = null
when resolving the actual values.Dariusz Kuc
07/13/2021, 2:25 AMMartin Brehovsky
07/13/2021, 2:26 AMMartin Brehovsky
07/13/2021, 2:27 AMDariusz Kuc
07/13/2021, 2:27 AMDataFetcherExceptionHandler
that is provided to the execution strategiesDariusz Kuc
07/13/2021, 2:28 AMDariusz Kuc
07/13/2021, 2:30 AMMartin Brehovsky
07/13/2021, 2:38 AMnull
as a properly loaded value and a failure.
One could argue if we care a lot about preserving null
as a valid value we should use a wrapper, something like Optional
to express this semantic, and I agree this would be perhaps the best approach. However since GraphQL does not support generic types, this would require creating a union type for each combination, and that does not scale well.
Pretty much exploring what other options we have and what would be the best pattern to use to support cases when we can partially fail vs we need completely fail.Martin Brehovsky
07/13/2021, 2:40 AMShane Myrick
07/13/2021, 5:24 AMCompletableFuture<DatafetcherResult<T>>
Martin Brehovsky
07/13/2021, 7:39 PM