# Usage

Example on how to use a simple subgraph request

1. Go to the subgraph explorer: <https://subgraph.sovryn.app/subgraphs/name/DistributedCollective/sovryn-subgraph/graphql>

<figure><img src="https://lh5.googleusercontent.com/dEwaTeD3qtB2rxGpB-Mr6bihq7Kd6O5zw76qRHfaGbnyYtfUUnO17H0M53MxBDDZxMlrDVhjhSZDIb3RosdSN5w3HI6CQqbj3-Gzu4byvsqkM3WFo4J8sz6uVWk4pSywmpE94Muu9aLwfNrHlySoBtc" alt=""><figcaption></figcaption></figure>

2. Decide what you want to query. For this example, we want to see how much SOV each user has voluntarily staked on the Staking contract.
3. Use the schema explorer to find the correct entities to query:

```graphql
{
  users {
    id
    stakeHistory {
      totalRemaining
    }
  }
}
```

4. Write your query in the left-hand column of the explorer. Read the GraphQL or Graph Protocol documentation for help with the graphQL syntax
5. Run your query. Take a look at the results:

<img src="https://lh6.googleusercontent.com/bXNrOmQTNCnrmIFKxqlBl83uDN9ZfDdWhPKfxPfFDeI4MfpoAtXtAdNhT_StCdb9dt5ZwaSj75ynblC_5GS3D60ze1UVq_P1N_LxpEp0ZLQZb7kzZNbmpF1RfUwDPRrYy_VHRLzh6RQLEFXfu1Dbog" alt="" data-size="original">

6. Edit query if needed. This result probably isn’t what you were looking for - here we are listing all users in alphabetical order by wallet address, even if they do not have any voluntarily staked SOV. We can change the query to this:

```graphql
{
    userStakeHistories(orderBy: totalRemaining, orderDirection: desc) {
        id
        totalRemaining
      }
}
```

This query returns results only for users who have voluntarily staked SOV, and orders the results with the largest current SOV staked amount first.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://build.sovryn.com/builder-portal/sovryn-sdk/the-graph/usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
