kodadot / loligo

Common good repository for Squid indexers in KodaDot
2 stars 1 forks source link

Optimize stats queries #64

Open vikiival opened 1 year ago

vikiival commented 1 year ago

While reviewing kodadot/nft-gallery#5120 I found query that was added in 5f64a482a0e7cdcdb92341d314fdc89ba3eaf86e

query collectionStatsById($id: String!) {
  stats: collectionEntityById(id: $id) {
    id
    base: nfts(where: { burned_eq: false }) {
      id
      currentOwner
      issuer
    }
    listed: nfts(where: { price_gt: "0" }) {
      id
      price
    }
    sales: nfts(where: { events_some: { interaction_eq: BUY } }) {
      id
      events(where: { interaction_eq: BUY }) {
        id,
        meta
      }
    }
  }
}

The reason is that when we returns this big chunks of data on frontend it creates more workload on frontend (to map it and parse)

roiLeo commented 1 year ago

Is there a workaround with collectionEntitiesConnection or nftEntitiesConnection?