0

I am trying to get count of NFTs locked on some address by policy ID using cardano graph ql.

I have this query in cardano-graphql (https://github.com/input-output-hk/cardano-graphql):

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
}

Do you have any idea how to fix this or what is wrong with my query?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.