Ordering and Sorting Data

Order and sort your responses

To sort accounts data we need to apply order_by command on data fields of our choice.

For example to fetch all spl-governance proposalsV2 where governing mint is Grape token sorted by drafting date. For this we can apply order order_by on draftAt.

circle-info

Use our GraphQL demo projectarrow-up-right to try out these queries in code.

The resulting query looks like

ProposalsV2 where governing mint is Grape token sorted by drafting date

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

Last updated