Trying figure out, while generating GQL schema,
why if :float
data in source var square_plot
exists (say 50
),
there is no ERR
but if it is NIL the code generates error
while i converting value so sqft with such code:
may be it seems no validation passes
CODE
field(:square_plot, :float) // my var is `50.0` in DB
field :square_plot_ft, :float do
if square_plot > 0 do
resolve(fn _args, %{source: source} -> {:ok, Float.round(source.square_plot*10.7639, 0)} end)
end
end
if value NOT NIL the GQL response
{
"data": {
"unit": {
"squareTotalFt": 1615.0,
"squareTotal": 150.0,
"squarePlotFt": 538.0,
"squarePlot": 50.0
}
}
}
if value is NIL the GQL response
"Internal server error"
and server ERR
** (exit) an exception was raised:
** (ArithmeticError) bad argument in arithmetic expression
(platform) lib/units_web/schema/object.ex:228: anonymous fn/2 in UnitsWeb.Schema.Unit.__abs
inthe_type__/1