Proposal: Additional query support

Hi @adamfuller

As we are going through different use cases for building analytics applications on The Graph, we are running into some limitations on the queries currently provided. We’d like to be able to do something like:

  1. Filtering data by nested field
{
  deposits( where: {reserve:{symbol:"DAI"}}) {
    reserve {
      symbol
    }
    amount
    timestamp
  }
}
  1. Sorting data by nested field
{
  deposits(
    orderBy:reserve.symbol
  ) {
    reserve {
      symbol
    }
    amount
    timestamp
  }
}
  1. Sorting data by multiple fields
{
  deposits(
    orderBy:timestamp
    orderDirection:asc
    orderBy:amount
    orderDirection:desc
  ) {
    reserve {
      symbol
    }
    amount
    timestamp
  }
}
  1. Grouping data by different fields.
  2. Math, string and array operators
2 Likes

Hi @huangkuan! Thanks, these are great ideas - we are hoping to improve the query planner (1,2,3), and Grouping data is definitely important for analytics use cases.
Can you give a bit more detail on what you mean by Math, string and array operators?

2 Likes

1,2,3 are definitely more important. The sooner this can be solved, the sooner we can rely less on an intermediate data layer.

Using the below data structure as an example:

{
  deposits( where: {reserve:{symbol:"DAI"}}) {
    reserve {
      symbol
    }
    amount
    timestamp
  }
}

A. amount stores the amount of tokens in 18 decimals. When I am displaying this value in a table, I want to get rid of the decimals. That would require a “divide” operator.

B. I want to be able to display amount and symbol in one field. That would require a string appending operator that connects both strings.