FuelLabs / fuel-indexer

*Archived* 🗃 The Fuel indexer is a standalone service that can be used to index various components of the Fuel blockchain.
140 stars 67 forks source link

Add support for aggregate GraphQL queries #1468

Open deekerno opened 12 months ago

deekerno commented 12 months ago

Aggregate queries allow for the return of statistical summaries of records that match certain criteria. For example, one may want to get the count of all transactions in the network. We could support the request with something like the following GraphQL query:

query {
  aggregateTransaction {
    count
  }
}

Additionally, we could allow for advanced aggregate queries by only allowing for certain inputs depending on the entity type and its fields. Here are a few example queries:

Get the average amount per transaction

query {
  aggregateTransaction {
    amountAvg
  }
}

Get the min, max, total, and average of all contract balances

query {
  aggregateContractBalance {
    amountMin
    amountMax
    amountSum
    amountAvg
  }
}

Here is some prior work from which we can take inspiration.

ra0x3 commented 11 months ago

@deekerno

aggregate$Entity {
  $field$Operation
}

Am I thinking about this correctly?