Applying Filters

Filter your accounts data like never before

Fetching an entire set of accounts data is powerful but filtering is what takes your DevEx to the next level. Most of the time you would be required to fetch a subset of your account data that fulfils a particular condition. Filtering is what enables that.

Imagine fetching only those V2 proposals, whose governing mint is grape token. Querying Solana like this was not possible at all before this. We will be using the where command for filtering.

Use our GraphQL demo project to try out these queries in code.

Get all ProposalsV2 where governing mint is Grape token

query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2(
    where: {governingTokenMint: {_eq: "8upjSpvjcdpuzhfR1zriwg5NXkwDruejqNE9WNbPRtyA"}}
  ) {
    name
    pubkey
  }
}

Get all ProposalsV2 where name is like Orca

query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2(
    where: {name: {_regex: "orca"}}
  ) {
    name
    pubkey
  }
}

Get all ProposalsV2 drafted after 1st Nov 23

query MyQuery {
  GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw_ProposalV2(
    where: {draftAt: {_gt: "1698796800"}}
  ) {
    name
    pubkey
  }
}

These filters enable experiences which otherwise would have taken months to develop before. Right now with Shyft GraphQL API, you can create them in just few API calls.

Last updated