dcgtc / dgrants

Decentralized Grant platform that implements quadratic funding.
GNU Affero General Public License v3.0
84 stars 39 forks source link

fix: optimises graph query pagination #523

Closed gdixon closed 2 years ago

gdixon commented 2 years ago

As described in the documentation here (thank you @mds1 for looking through this with me!): https://thegraph.com/docs/developer/graphql-api#example-3

We can up the query limit to 1000 and we will also achieve better performance if we step through the results using id_gt (the graph stores data in ascending alphanumeric order based on the ID field rather than the creation time).

--

I've tested this out using the old subgraph and everything is pulled in correctly, it can also be tested in isolation here: https://thegraph.com/hosted-service/subgraph/dcgtc/dc-gitcoin-grants-matic?selected=playground

{
  grants(
    first: 1000, 
    where: {
      id_gt: "0x01",
      lastUpdatedBlockNumber_gte: "19841897"
    }
  ) {
    id
    owner
    payee
    metaPtr
    lastUpdatedBlockNumber
  }
}