cartesi / rollups

Cartesi Rollups
30 stars 12 forks source link

fix(graphql-server): integer coercion in variables #239

Closed gligneul closed 1 year ago

gligneul commented 1 year ago

Without this patch, the integer variables are always interpreted as BigInts.

Fixes https://github.com/cartesi/rollups-node/issues/81

tuler commented 1 year ago

Is it necessary to check the value to decide how to parse?

gligneul commented 1 year ago

Is it necessary to check the value to decide how to parse?

The other options are:

tuler commented 1 year ago

Don't you know the type of the variable from its definition?

gligneul commented 1 year ago

@tuler, when deserializing from a JSON, the library doesn't know the type of the value it expects. It reads all integer values as int64, so it needs to change the type given the value. More info: https://docs.rs/juniper/latest/juniper/trait.ScalarValue.html