> For the complete documentation index, see [llms.txt](https://docs.shyft.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.shyft.to/solana-indexers/graphql-apis/building-queries.md).

# Building Queries

We will take the example of the **spl-governance** program and build graphQL queries to fetch data, instead of the usual **getProgramAccounts()** call.

{% hint style="info" %}
Use our [GraphQL demo project](https://github.com/Shyft-to/community-projects/tree/main/graphql-demo) to easily get started and try out these queries in code.
{% endhint %}

<mark style="color:yellow;">**#Get all proposalsV2 accounts**</mark>

```graphql
query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2 {
    abstainVoteWeight
    closedAt
    denyVoteWeight
    descriptionLink
    draftAt
    executingAt
    executionFlags
    governance
    governingTokenMint
    lamports
    maxVoteWeight
    maxVotingTime
    name
    options
    reserved1
    signatoriesCount
    signatoriesSignedOffCount
    signingOffAt
    startVotingAt
    state
    tokenOwnerRecord
    vetoVoteWeight
    voteThreshold
    voteType
    votingAt
    votingAtSlot
    votingCompletedAt
    pubkey
  }
}

```

Note how we have included all the data fields that are available to us, you can cherry pick fields that are useful to you. For example if you only want <mark style="color:yellow;">names</mark> and <mark style="color:yellow;">addresses</mark> of the proposals. The the query becomes like

```graphql
query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2 {
    name
    pubkey
  }
}
```

<figure><img src="/files/16Ef3yZ76JIW5zQ0XBkY" alt=""><figcaption><p>Fetching All Proposals V2 from spl-governance</p></figcaption></figure>

By default the API will return <mark style="color:yellow;">1000 accounts</mark> data in response. You can control how many accounts you need by specifying <mark style="color:yellow;">**limit**</mark>**.** The query becomes like below.

```graphql
query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2(limit: 100) {
    name
    pubkey
  }
}
```

Ideally there would be thousands of accounts in a program, so lets see how can we paginate and get more responses.
