cardano-graphql
cardano-graphql copied to clipboard
utxo_aggregate sum error
I am trying to send this query to get amount of NFTs locked on address by policyId:
query { utxos_aggregate( where: { _and: { address: { _eq: $address }, tokens: { asset: { policyId: { _eq: "d6fe6efa7788cb70e57a91891605e3694352cabb4837e870610300e9"} } } } } ){ aggregate { sum { tokens { quantity } } } } }
It works well with count aggregate, but in case of sum aggregate it returns this error:
{ "errors": [ { "message": "Cannot return null for non-nullable field Query.utxos_aggregate.", "locations": [ { "line": 2, "column": 3 } ], "path": [ "utxos_aggregate" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "exception": { "stacktrace": [ "Error: Cannot return null for non-nullable field Query.utxos_aggregate.", " at completeValue (/app/node_modules/graphql/execution/execute.js:560:13)", " at completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)", " at resolveField (/app/node_modules/graphql/execution/execute.js:435:10)", " at executeFields (/app/node_modules/graphql/execution/execute.js:275:18)", " at executeOperation (/app/node_modules/graphql/execution/execute.js:219:122)", " at executeImpl (/app/node_modules/graphql/execution/execute.js:104:14)", " at Object.execute (/app/node_modules/graphql/execution/execute.js:64:35)", " at /app/node_modules/apollo-server-core/dist/requestPipeline.js:261:48", " at Generator.next (<anonymous>)", " at /app/node_modules/apollo-server-core/dist/requestPipeline.js:8:71" ] } } } ], "data": null }
We've got a similar issue so I'll just add to this one.
Query:
query UTxO($addresses: [String]!) {
utxos(where: { address: { _in: $addresses } }) {
address
txHash
index
value
tokens {
asset {
assetId
}
quantity
}
}
}
Variables:
{
"addresses": [
"addr1q8l5hxd2kk2qd9vvl5mk7txrzezrlnsgym2utnt62lryphg5kkvr22hlffqdj63vk8nf8rje5np37v4fwlpvj4c4qryqz4z0sm"
]
}
Returns:
{
"errors": [
{
"message": "Cannot return null for non-nullable field Token.asset.",
"locations": [
{
"line": 8,
"column": 7
}
],
"path": [
"utxos",
0,
"tokens",
0,
"asset"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"stacktrace": [
"Error: Cannot return null for non-nullable field Token.asset.",
" at completeValue (/app/node_modules/graphql/execution/execute.js:560:13)",
" at completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)",
" at resolveField (/app/node_modules/graphql/execution/execute.js:435:10)",
" at executeFields (/app/node_modules/graphql/execution/execute.js:275:18)",
" at collectAndExecuteSubfields (/app/node_modules/graphql/execution/execute.js:713:10)",
" at completeObjectValue (/app/node_modules/graphql/execution/execute.js:703:10)",
" at completeValue (/app/node_modules/graphql/execution/execute.js:591:12)",
" at completeValue (/app/node_modules/graphql/execution/execute.js:557:21)",
" at completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)",
" at /app/node_modules/graphql/execution/execute.js:618:25"
]
}
}
}
],
"data": {
"utxos": [
null
]
}
}
As far as I know, this issue affects addresses that hold some tokens but not all, for example, Hosky is fine. After a few hours, some tokens become normal. My guess is that some information about native assets was missing or not syncing fast enough, even though our node had caught up to the tip. What is the root cause, and how can we improve it?