question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

docs: stringify bigint for typed variables

See original GitHub issue

Hi 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:open
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rikinskcommented, Oct 30, 2019

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

0reactions
rikinskcommented, Oct 30, 2019

@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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found