# 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="https://2394289113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4XnSsBH76iytbI7NwX5o%2Fuploads%2FeThjlw6dFzYIQCVF113x%2Fezgif.com-video-to-gif%20(2).gif?alt=media&#x26;token=d285f4b4-1354-4aba-b0a0-848c2958c2b7" 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.
