cardano-foundation/cardano-graphql

Query for block reports "Cannot return null for non-nullable field Token.asset"

Opened this issue · 0 comments

Ask a question

curl -X POST -H "Content-Type: application/json" -d '{"query": "{ blocks(where: { number: { _eq: 9751450}}) {hash number epochNo slotNo forgedAt size previousBlock { hash } transactions {block{hash} blockIndex hash fee size includedAt inputs {address sourceTxHash sourceTxIndex value tokens {asset {assetId assetName policyId} quantity}} outputs (order_by: { index: asc }) {address txHash index addressHasScript value paymentCredential tokens { asset {assetId assetName policyId} quantity}}}} }"}' http://localhost:3200/graphql |jq

{
    "errors": [
        {
            "message": "Cannot return null for non-nullable field Token.asset.",
            "locations": [
                {
                    "line": 1,
                    "column": 230
                }
            ],
            "path": [
                "blocks",
                0,
                "transactions",
                8,
                "inputs",
                7,
                "tokens",
                235,
                "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 completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)",
                        "    at /app/node_modules/graphql/execution/execute.js:618:25",
                        "    at Array.forEach (<anonymous>)"
                    ]
                }
            }
        },
        {
            "message": "Cannot return null for non-nullable field Token.asset.",
            "locations": [
                {
                    "line": 1,
                    "column": 383
                }
            ],
            "path": [
                "blocks",
                0,
                "transactions",
                8,
                "outputs",
                1,
                "tokens",
                235,
                "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": {
    "blocks": [
      {
        "hash": "5a8880a94b8d37860c6c977c2bc6bdef85066a8a014747b141bf32fd336a5fd3",
        "number": 9751450,
        "epochNo": 458,
        "slotNo": "112604865",
        "forgedAt": "2024-01-02T04:52:36Z",
        "size": 28346,
        "previousBlock": {
          "hash": "79c88c83efaf466c2de99e1b9757cb7dc6cb9bbb799c8ae68d8c6dc1288fdf5f"
        },
        "transactions": [
          {
            "block": {
              "hash": "5a8880a94b8d37860c6c977c2bc6bdef85066a8a014747b141bf32fd336a5fd3"
            },
            "blockIndex": 13,
            "hash": "b78d559f7b9672d0cb51fd53207703e7e5f197baca4d2236f0e641bc2bcfcd97",
            "fee": "171573",
            "size": 363,
            "includedAt": "2024-01-02T04:52:36Z",
            "inputs": [
              {
                "address": "addr1qyrdaazl8g64ktvln7rr55vvt9d0kqx8du8v9gaj9agz3fnzwn52yzf9lduqql5tsp5a6d73vyt8zc8unxs8t7pdkszqxj4eq3",
                "sourceTxHash": "8dfba459329e1a8662a07eac5af70ecb46cd3bdb50f910cf2c3b5ed334dbe93e",
                "sourceTxIndex": 0,
                "value": "30927195",
                "tokens": []
              }
            ],
"outputs": [
              {
                "address": "addr1qyfzx4axz2k6fw9q7r3p364zl24vdze4p3f5a6mg9t6d5enzwn52yzf9lduqql5tsp5a6d73vyt8zc8unxs8t7pdkszqu8tj8c",
                "txHash": "b78d559f7b9672d0cb51fd53207703e7e5f197baca4d2236f0e641bc2bcfcd97",
                "index": 0,
                "addressHasScript": false,
                "value": "74385507",
                "paymentCredential": "122357a612ada4b8a0f0e218eaa2faaac68b350c534eeb682af4da66",
                "tokens": []
              }
            ]
          },
.........

Why does Error and Data appear at the same time?
The query data originally reported an error, but there is still data returned