Open dsbw opened 2 years ago
We usually wrap the request fn with additional processing if it’s needed, there’s nothing automatic unfortunately
Oh, so it's like "I know that this field is double so I'll convert it?"
I was thinking there might be a way to query the library to say "Hey, what type is this supposed to be?"
Howdy,
I've been using this (very helpful, thank you!) library for a project where I take data from a database via graphql and then put it into a JavaFX table control, which has raised an interesting issue that I'm wondering how other people handle.
Let's say I have a database field which is some kind of floating point (
double
ormoney
or whatever). It's specified asFloat
on the GraphQL side, but when it's a round number, like 1.0, the JSON comes in as "1" and ends up as aLong
. Most of the time, this isn't a problem, but using aLong
in the JavaFX table column set forDouble
causes a type exception.I think my handling for this is going to be on the table side, so that it detects longs and coerces to doubles accordingly, which will work for the table but not for any other circumstance where the Long/Double discrepancy might arise.
The real issue is, I think,
json/read-str
, which doesn't take into account the GraphQL type (and why would it?), so I was wondering if anyone else had the problem and how they'd handled it.