Hello guys!
First of all thanks for all the great effort you’re putting into RedwoodJS, for a seasoned Rails developer like me this checks a lot of boxes and feels really good.
I’m building a small app to get familiar with the framework where I have a Product model with a name
(string) a price_in_cents
(integer) fields.
I’ve scaffolded the UI and tried to add a new product, but when I save it I get a GraphQL error: Expected type Int. Int cannot represent non-integer value: "100"
. I’m assuming this happens because the <input>
sends the value as a string, while my model defines that field as an Int
.
Is that the case or am I missing something? I’m new to GraphQL, so that might be the case
What’s the best way (and where’s the best place) to coerce the value to an integer so that it doesn’t fail validation?
This similar example works around the issue by modeling the price
as a String
, which honestly just doesn’t feel right
Bonus question: would it be possible for the scaffold generator to generate an <input type="number" step="1">
to map Int
fields? It won’t fix the previous issue, but it would improve the experience and minimize user errors.
Thanks!