I'm using Hasura to connect to my Postgres database and I'm trialling a few queries using the Hasura console and I've noticed when I query for my id
column which is stored as a 64-bit integer the number is coming through incomplete almost. For example, if my id
is 1,234,567,891,234,567,891
(19 digits) the query will return 1,234,567,891,234,564,000
- the same number of digits but with 0's as the last few. According to the Hasura docs 64-bit integers are supported and I'm pretty certain my stored values fall within that range.. So I guess I'm pretty lost on why this is happening.. Any help or advice would be greatly appreciated.
Asked
Active
Viewed 253 times
0

SkinnyBetas
- 461
- 1
- 5
- 27
-
Interesting. The signed integer max is indeed 19 digits, but 9,223,372,036,854,775,807. Are you actually using the values in your post? If so I'll ask around on discord for some attention. – Jared Beekman Jun 03 '21 at 03:52
-
Those aren't the exact values - but the ones actually used fall well within the range. – SkinnyBetas Jun 03 '21 at 04:00
-
That looks like the integer is being parsed into a double-precision float. If you're querying this result and getting JSON back, are you parsing the JSON with something that can decode the JSON number into an integer type? If you look at the JSON response body before it is parsed, is the value correct? – loganfsmyth Jun 03 '21 at 04:01
-
I've tried using bigint, so BigInt(id) but it's still wrong. Could be missing something there – SkinnyBetas Jun 03 '21 at 05:19
-
1This could be a JSON limitation. You can try using the flag `HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES=true`, this will convert the numeric types into string when generating the JSON response. – Leonardo Alves Jun 03 '21 at 13:28
-
I've tried HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES and it works great for the id actually and avoids the overflow. However, I have other values that I need to remain as there numeric types for calculations. I have no need to stringify a number such as 100 for example... It would be very helpful if instead I was able to specify only stringify bigints – SkinnyBetas Jun 09 '21 at 05:54