Skip to main content

Example: User Positions

Fetch user positions with aggregate statistics.

Query​

Query

query GetUserPositions($accountId: String!, $limit: Int!) {
  stats: positions_aggregate(where: { account_id: { _eq: $accountId } }) {
    aggregate {
      count
      sum { shares }
    }
  }
  positions(
    where: { account_id: { _eq: $accountId } }
    order_by: { shares: desc }
    limit: $limit
  ) {
    id
    shares
    vault {
      term_id
      current_share_price
      market_cap
      term {
        atom { label image }
      }
    }
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results