Skip to content

NodleCode/subquery

Repository files navigation

subquery-nodle

How to use query on Subquery server.

Subquery is a gaphql based API server. As it's the case with graphql you can either use HTTP to deliver your queries to the server using either of the two GET or POST methods explained here, or depending on the language of your client applications you use a graphql library and query the server in a way that's more idiomatic in your own coding language. The direct HTTP requests could be useful for the tests created in Postman or Insomnia, while the latter approach could be preferred inside your applications. Below you see the list of the queries that this project is supporting at the moment:

Query transaction history

query TransactionHistoryByAddress ($address: String!){
	systemTokenTransfers (filter: {
      or: [
	{
	  fromId: {
	    equalTo: $address
	  }
	},
	{
	  toId: {
	    equalTo: $address
	  }
	}
      ]
    }) {
      nodes {
	id
	fromId
	toId
	amount
	extrinsicId
	timestamp
      }
    }
}

Query vesting schedules for an address

query VestingSchedulesByAddress($address: String!){
  vestingSchedules (filter: {
      signer: {
	equalTo: $address
      }
    }) {
      nodes {
	id
	signer
	to
	data
      }
    }
}

How to get transfer lists by specific address & timestamp

query transfersByFields($from: String!, $to: String!) {
  systemTokenTransfers(
    filter: {
      and: [{ fromId: { equalTo: $from } }, { toId: { equalTo: $to } }]
    }
  ) {
    nodes {
      id
      fromId
      toId
      timestamp
    }
  }
}
query transfersByFields(
  $from: String!
  $to: String!
  $start: Date!
  $end: Date!
) {
  systemTokenTransfers(
    filter: {
      and: [
        { fromId: { equalTo: $from } }
        { toId: { equalTo: $to } }
        { timestamp: { greaterThanOrEqualTo: $start } }
        { timestamp: { lessThanOrEqualTo: $end } }
      ]
    }
  ) {
    nodes {
      id
      fromId
      toId
      timestamp
    }
  }
}