Skip to content

Query Examples

Timur Ramazanov edited this page Jun 18, 2019 · 14 revisions

✔️ Supported

Here's a few examples of what's already possible with Astrograph. You can play with these queries in demo playground. Feel free to open an issue if you experience any problems.

  • Get operations for account

    Query
    query($id: AccountID!) {
      account(id: $id) {
        id
        operations(last: 10) {
          nodes {
            id
            kind
            dateTime
          }
        }
      }
    }
    Query (with payment details)
    query($id: AccountID!) {
      account(id: $id) {
        id
        operations(last: 10) {
          pageInfo {
            startCursor
            endCursor
          }
          nodes {
            id
            kind
            dateTime
            ... on PaymentOperation {
              sourceAccount {
                id
              }
              destination {
                id
              }
              asset {
                code
                issuer {
                  id
                }
              }
              amount
            }
          }
        }
      }
    }
  • Get top 10 asset holders (#155)

    Query
    query($asset: AssetID!) {
      asset(id: $asset) {
        code
        issuer {
          id
        }
        balances(last: 10) {
          nodes {
            account {
              id
            }
            balance
          }
        }
      }
    }
  • Filter accounts by data entry key/value (#164)

    Query
    query {
      accounts(
        data: {
          name: "foo",
          value: "bar"
        },
        first: 5
      ) {   
        nodes {
          id
        }
      }
    }
  • Get assets issued by the account (#159)

    Query
      {
        account(id: "GBSTRUSD7IRX73RQZBL3RQUH6KS3O4NYFY3QCALDLZD77XMZOPWAVTUK") {
          assets(first: 5) {
            nodes {
              code
              holdersCount
              unauthorizedHoldersCount
              totalSupply
              authRequired
            }
          }
        }
      }
  • Find payment paths (#170)

    Query
    {
      findPaymentPaths(
        sourceAccountID: "GA4DMQ3VSHIVROQ42PJVJOD7X4PYT5BXAWV672CAWOWIADXC3RGZEOMZ",
        destinationAsset: "ETH-GCNSGHUCG5VMGLT5RIYYZSO7VQULQKAJ62QA33DBC5PPBSO57LFWVV6P",
        destinationAmount: "3.5647"
      ) {
        sourceAsset {
          id
        }
        destinationAsset {
          id
        }
        sourceAmount
        path {
          id
        }
      }
    }
    
  • Subscribe to new ledgers

    Query
      subscription {
        ledgerCreated {
          seq
          header {
            ledgerVersion
            previousLedgerHash
            txSetResultHash
            baseFee
            baseReserve
            maxTxSetSize      
          }    
        }
      }
    
  • Subscribe to offer modification events

    Query
      subscription {
        offer(args: {mutationTypeIn: [CREATE, UPDATE, REMOVE]}) {
          mutationType
          accountID
          offerID    
          values {
            id
            seller { id }
            selling { ...assetFields }
            buying { ...assetFields }
            amount
            price
            passive
          }
        }
      }
    
      fragment assetFields on Asset {
        id
        code
        issuer {
          id
        }
        native
      }
    

🕦 In orbit

  • Filter transactions by memo (#97)
  • Get a list of signers who authorized particular transaction or operation (#163)
  • Find all transactions or operations signed by particular account (#163)
Clone this wiki locally