Subgraph data (GraphQL)

The Graph and GraphQL

The Graph is a decentralized protocol for indexing and querying data from blockchains, starting with Ethereum. What that means: it is an easier way to retrieve specific data from the blockchain, within the ethos of web3, with the advantages of decentralization and reliability.

GraphQL is the underlying query language utilised in The Graph. What is the difference between standard RESTFUL API calls and GraphQL calls? The difference is that traditional APIs require the developers to create specific endpoints for users that return specific data. If the user requires more information, they may need to make multiple API calls, sometimes hundreds of API calls, to get the information they require. With The Graph (which uses GraphQL), only one call is needed to a subgraph, as long as the developer has created a flexible schema.

For more information on The Graph and the underlying GraphQL, see this GraphQL primer.

If you are consuming GraphQL data in your app, we'd recommend using a fully featured package such as Apollo or a minimal implementation such as GraphQL-Request.

Aave Arc Subgraph

To view the source of our subgraphs, see Github repo.

ToolsLink

Graph Explorer Playground

(HTTP) Query API Endpoint

(WS) Subscription API Endpoint

wss://api.thegraph.com/subgraphs/name/aave/aave-arc

How to use the playground

If you visit the above playground link in your browser, you will be taken to The Graph’s playground, where you can easily construct and test GraphQL queries.

  • To execute your query, select the purple play button.

  • The query results will be returned in the middle column.

  • To find out what data is available, use the ‘Schema’ column on the right, which can be explored to discover the underlying data.

  • You can also type in the left column and use the auto-complete to find the correct query/types.

Common Gotchas

  • All address values (e.g. when used for id) must be in lower case format.

  • The ID of reserves is the address of the asset and the address of the market's LendingPoolAddressProvider, in lower case.

  • When using the raw endpoints, depending on the type of numeric value queried, it will be returned either in wei units (i.e. 10^18), the decimals of the asset itself (i.e. 10^6 for USDC), or ray units (i.e. 10^27).

  • Each results 'page' returns 100 entries by default. This can be increased to a maximum of 1000 entries per page.

    • E.g. to list the next 1000 entries, append something similar to: (skip:1000, first: 1000) to your query's parameters.

    • This also applies to nested entries, such as arrays.

  • All data on our Graph endpoint is static. Therefore to get the latest balance of a user (which includes the interest earned up to that second), you would need to either calculate it yourself or make a balanceOf() call to the aToken contract.

Accessing GraphQL data from your app

The recommended way is to use a client library that can take care of the 'plumbing' to ensure you have up to date data (with caching sometimes included). Internally we use Apollo, but there are many options depending on your programming language, see the official GraphQL page.

If for some reason you cannot use a client library (e.g. querying via Postman), then you can create a POST request to our subgraph's HTTP endpoint, with header: Content-Type: application/json and the body consisting of your query on one line in quotations. For example:

{"query": "{ reserves (where: {usageAsCollateralEnabled: true})  { id name price {id} liquidityRate variableBorrowRate stableBorrowRate}}" }

Last updated