I was actually seeding my database with data using the
faunadb-js under the hood. Running plan vanilla
Agreed. I wasn’t expecting the data to be validated as per graphql per-say. What I was hoping was that pulling data out via the graphql interface would attempt a “cast” when I pull it out? Then error out if the cast didn’t work?
It’s interesting when you have data in collections without explicitly columns and column type definitions but are working to pull it out through a strongly typed interface like Graphql, you hit these hurdles.
That makes sense. This seems to be the solution given how things are built now. Just thinking out loud, its unfortunate to have to, everywhere you are putting in a number that should be a double, explicitly casting to a double in case it is a whole number. It would be nice if the user just had to think in “one place” and let the system “automagically” help us. In my mind there are two possiblities:
- One option, in SQL we have the table definitions. In FaunaDB, maybe have a weak (and optional) collection definition so that validation happens when you put data into fields it has a type for, but otherwise put in whatever you get?
- Another option, have the system attempt a cast for data being pulled out. Some casts will work and others will not. So a string to a Double will error out, but an int to a double will not, etc…
Anyway these are just initial thoughts.
Gotcha. Will try the
ToDouble() solution for now. Thanks!