user4516: I'm working on an application which for some of its features has to calculate the total balance of a wallet for a given time range. Here's a query that I've written (I don't have access to the original code at the moment, the following snippet was copied and adjusted from this example, which I also used originally, so it might contain some mistakes if you actually try to run it):
query getBalanceBetweenBlocks($address: String!, $min: Int!, $max: Int!) {
  blocks(where: {number: {_gte: $min, _lte: $max}}) {
    transactions(where: {_or: [
      {inputs:  {address: {_eq: $address}}}
      {outputs: {address: {_eq: $address}}}
    ]}) {
      inputs_aggregate(where:  {address: {_eq: $address}}) {aggregate {sum {value}}}
      outputs_aggregate(where: {address: {_eq: $address}}) {aggregate {sum {value}}}
    }
  }
}

It works correctly, but only if the [$min; $max] range is fairly small, for example $max = $min + 2000. If I try to increase it to, say, $maxblock = $minblock + 5000 the aggregated result is wrong, and I believe it's happening because the [$min; $max] range is actually cut off at some point artificially limiting how much data can be processed per single GraphQL query.
Also, I've tried writing the same query in SQL to interact with cardano-db-sync, and it does work correctly. Unfortunately, I cannot use cardano-db-sync directly which is why I'm using cardano-graphql in the first place.
Does anybody know if that's a problem with cardano-graphql or maybe some other thing on top of it (GraphQL, Hasura etc.), and if there's a way to deal with this problem? While it does perform fairly well, I'd like to see whether aggregating all the inputs/outputs at once is more efficient than doing so in batches (which would also let me simplify the application code in the process).

user28: cardano-graphql has, according to their wiki, a query result limit of 2,500 items and depth limit 3.

4516: <p>I'm working on an application which for some of its features has to calculate the total balance of a wallet for a given time range. Here's a query that I've written (I don't have access to the original code at the moment, the following snippet was copied and adjusted from <a href="https://input-output-hk.github.io/cardano-rest/migration-guide/explorer-api/#apiblockblockhashaddressaddress" rel="nofollow noreferrer">this example</a>, which I also used originally, so it might contain some mistakes if you actually try to run it):</p>
<pre><code>query getBalanceBetweenBlocks($address: String!, $min: Int!, $max: Int!) {
  blocks(where: {number: {_gte: $min, _lte: $max}}) {
    transactions(where: {_or: [
      {inputs:  {address: {_eq: $address}}}
      {outputs: {address: {_eq: $address}}}
    ]}) {
      inputs_aggregate(where:  {address: {_eq: $address}}) {aggregate {sum {value}}}
      outputs_aggregate(where: {address: {_eq: $address}}) {aggregate {sum {value}}}
    }
  }
}
</code></pre>
<p>It works correctly, but only if the <code>[$min; $max]</code> range is fairly small, for example <code>$max = $min + 2000</code>. If I try to increase it to, say, <code>$maxblock = $minblock + 5000</code> the aggregated result is wrong, and I believe it's happening because the <code>[$min; $max]</code> range is actually cut off at some point artificially limiting how much data can be processed per single GraphQL query.</p>
<p>Also, I've tried writing the same query in SQL to interact with cardano-db-sync, and it <strong>does</strong> work correctly. Unfortunately, I cannot use cardano-db-sync directly which is why I'm using cardano-graphql in the first place.</p>
<p>Does anybody know if that's a problem with cardano-graphql or maybe some other thing on top of it (GraphQL, Hasura etc.), and if there's a way to deal with this problem? While it does perform fairly well, I'd like to see whether aggregating all the inputs/outputs at once is more efficient than doing so in batches (which would also let me simplify the application code in the process).</p>
 28: <p><code>cardano-graphql</code> has, <a href="https://github.com/input-output-hk/cardano-graphql/wiki/Security#depth-limit" rel="nofollow noreferrer">according to their wiki</a>, a query result limit of 2,500 items and depth limit 3.</p>
