hasura / hasura/graphql-engine

Bigint in Postgres doesn't work with HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES = true

Open
#10,158 3 comments 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: 2.37.0
PostgreSQL 16.0

### Environment

cloud and docker CE

### What is the current behaviour?

I have enabled the HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES = true and when I run mutation with bigint numbers are still rounded

eg I have the following sql query

```
update following set active=0 where
account_id = 264988535 and following_user_id in (809191427645181212, 720487892670410752 )
```

which translates to

```
mutation MyMutation($account_id: bigint, $follower_account_id: [bigint!] ) {
update_following(where: {_and: {account_id: {_eq: $account_id}, following_user_id: {_in: $follower_account_id}}}, _set: {active: 0}) {
affected_rows
}
}
```

with query parameters

```
{
"account_id": 264988535,
"follower_account_id": [809191427645181212, 720487892670410752]
}
```

My results are 0

```
{
"data": {
"update_following": {
"affected_rows": 0
}
}
}
```
If I run the same sql query on postgres I get 2 rows updated

After tracing the query on postgres I found out that the rounding takes place

![image](https://github.com/hasura/graphql-engine/assets/30319498/a138abfb-7471-4d55-b163-a5ad93263251)

### What is the expected behaviour?

bigint numbers should not get rounded when using HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES = true

### How to reproduce the issue?

I am running hasura cloud but I also tried to shoot a docker with the same config and still had the same behaviour

### Screenshots or Screencast

When I run the same kind of function but as query and not mutation I get results as expected

```
query MyQuery{
following (
where: {
_and: [
{account_id: {_eq: 264988535 }},
{following_user_id: {_in: [809191427645181212, 720487892670410752]}}
]
}
)
{
account_id
following_user_id
active
}
}
```

Results:

```
{
"data": {
"following": [
{
"account_id": "264988535",
"following_user_id": "720487892670410752",
"active": 0
},
{
"account_id": "264988535",
"following_user_id": "809191427645181212",
"active": 0
}
]
}
}
```

### Please provide any traces or logs that could help here.

### Any possible solutions/workarounds you're aware of?

### Keywords

bigint stringify postgres

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the mutation with HASURA_GRAPHQL_STRINGIFY_NUMERIC_TYPES enabled and compare its bigint parameters with the equivalent query, then trace how the mutation values reach PostgreSQL. Done means the two large bigint values are preserved without rounding and the mutation reports two affected rows.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.