Open atomkirk opened 3 years ago
I need to double check with the spec, but this does seem like a bug. I would expect that returning nil
from a resolver would simply prevent the union resolve_type from running at all and go ahead with a nil
value. Will investigate.
Was not able to reproduce this.
In the example the resolve_type
function won't match since the first argument is the returned value of the resolver, so %{boolean: bool}
, %{string: str}
or nil
and not a scalar boolean or string. The behaviour seen likely stems from that.
When nil
is returned by the resolver, the final result has nil
in the response so this is correct.
Environment
Expected behavior
Given this schema:
I would expect the union resolve_type to not get called if {:ok, nil} is returned, but it is called…
Actual behavior
It returns an error that string_value.string returns nil from a non-nullable type. (it shouldn't get that far, all of value should be null
And, if I return
nil
from resolve_type, it returnsvalue: {}
in the response. Basically, a nullable union field doesn't seem to work…