Query Examples for The Graph

Sample Queryies of The ENS Governance Subgraph.

In this article, we are taking a look at sample queries to show you how to query the ENS Governance subgraph. In our example, we wish to learn more about a particular delegate of the ENS DAO.

Example: Querying ENS DAO Delegator Stats.

Getting Network Stats About DAO Delegates

ENS governance uses a delegate model to help the DAO represent the interests of members who can’t personally consider and vote on each proposal. As such, delegates participate in governance votes by voting on behalf of their delegators.

Example Query.

We want to learn more about a particular delegate by querying information about the delegate from the subgraph. To do so, we need to specify the ID of the delegate of our choice. For example, a quick search has resulted in the random ID 0x8d07d225a769b7af3a923481e1fdf49180e6a265. In our query, we are going to specify which data we want to query by adding the delegate’s ID to our query.

We’d like to understand how many token holders the delegate represents, how many votes were delegated to this ID, and how the delegate voted on the first three governance proposals. If available, we’d also like to see if the delegate has provided a reason for voting for or against a proposal. 

So let’s do this by querying the following data:

Copy to Clipboard

Result of Example Query.

Let’s take a look at the result of our example query.

Copy to Clipboard

We can see the delegate has voted a total of 16 times, represents 248 token holders who have delegated 9681 votes to the delegate. Also, the delegate voted in favor of the first three votes but gave no reason on the reason why.