vegaprotocol / data-node

A rich API server for Vega Protocol
https://vega.xyz
Other
3 stars 1 forks source link

TotalCount is always zero #729

Closed mattrussell36 closed 2 years ago

mattrussell36 commented 2 years ago

The totalCount field for the following query is always zero. Worth checking the same bug doesn't exist for other new paginated queries.

query {
    party(id: $partyId) {
      id
      tradesPaged(marketId: $marketId, pagination: $pagination) {
        totalCount
        edges {
          node {
            id
          }
        }
      }
    }
  }
gordsport commented 2 years ago

Hey @guoguojin Looks like this could be related to:

guoguojin commented 2 years ago

As mentioned on Slack, I left this as a TODO item as I was looking for a good way to implement this as we need to issue multiple queries to the database in order to get the count and the paged data.

It looks like I can do what I want by using a query batch using the pgx drivers so I'll implement this now for this and other paginated queries that have already been implemented.

guoguojin commented 2 years ago

I've changed the headline on this ticket because it applies to other connection functions too and I will update them all now as it appears my changes for Trades is working nicely.

guoguojin commented 2 years ago

After much discussion, we have decided to leave this as it is for the time being due to the performance impact of counting rows that can be incurred for large datasets. We will come back to it if it is determined that this feature is absolutely necessary to implement for the API. For the time being we have left the TotalCount as part of the Connection definition in order to comply with this standard defined for GraphQL pagination: https://relay.dev/graphql/connections.htm which has been adopted by FaceBook and may be supported by other GraphQL client libraries.

gordsport commented 2 years ago

closing for now - to be reopened if/when we decide we will do this