docs: stringify bigint for typed variables
See original GitHub issueHi guys,
I am using typed variables in my GraphQL statement to insert into a table with a BigInt column. The docs say use ‘String’, but with string I get {"errors": [{"extensions": {"path": "$.variableValues.var_contract_id", "code": "parse-failed"}, "message": "expected Text, encountered Number"}]}
.
My code is:
query = """ mutation insert_tbl_rslt_option_price_hist (
$var_contract_id: bigint!, $var_bid: String!, $var_ask: numeric!, $var_tick_ts: timestamptz!)
{ insert_tbl_rslt_option_price_hist(objects: {
contract_id: $var_contract_id, bid: $var_bid, ask: $var_ask, tick_ts: $var_tick_ts
}) { returning { landed_ts } } } """
variables = {
"var_contract_id": conid,
"var_bid": bid,
"var_ask": ask,
"var_tick_ts": tick_ts
}
url = 'http://' + os.getenv('HASURA_IP') + ':' + os.getenv('HASURA_INTERNAL_PORT') + '/v1/graphql'
headers = {
"content-type": "application/json",
"x-hasura-admin-secret": os.getenv('HASURA_ADMIN_SECRET')
}
request = requests.post(url=url, json={'query': query, 'variables': variables}, headers=headers, timeout=1)
The query works when I use bigint!
instead of string (as I would expect 😃 )
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
BigInt - JavaScript - MDN Web Docs
BigInt values represent numeric values which are too large to be represented by the number primitive.
Read more >BigInt - ThinkBucket
BigInt (ES2020) is a built-in object that provides a way to represent whole numbers larger than 2**53 - 1 , which is the...
Read more >safe-stable-stringify - npm
stringify.configure(options) · bigint {boolean} If true , bigint values are converted to a number. · circularValue {string|null|undefined| ...
Read more >source text access for `JSON.parse()` and `JSON.stringify()`
Replacers, callbacks that are passed to JSON.stringify() and ... reviver assumes that properties whose names end with '_bi' contain bigints.
Read more >Working with fields (Concepts) - Prisma
BigInt fields are represented by the BigInt type (Node.js 10.4.0+ required). ... If you attempt to use JSON.stringify on an object that includes...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Wanted to add that the docs currently are a little confusing. The Hasura Type mentioned is more like the format it expect the variable in and not the GraphQL type to be used. We’ll update the docs to make this more clear
@dvasdekis Take a look at #1504 & #1523 for context. Your value will be saved as bigint in postgres eventually. Its a just a json limitation for which bigints need to be stringified