Skip to content

Pagination with GraphQL - Count attribute #946

Closed Answered by vitorxfs
vitorxfs asked this question in Q&A
Discussion options

You must be logged in to vote

I just found the solution, so I'll keep this here just in case someone has the same question.

I'm querying pokemon_v2_pokemon_aggregate, but only passing the where variable, so I can get the total number of pokémons with the specified filters:

  query samplePokeAPIquery(
    $limit: Int,
    $offset: Int,
    $orderBy: [pokemon_v2_pokemon_order_by!],
    $where: pokemon_v2_pokemon_bool_exp
  ) {
    pokemon_v2_pokemon_aggregate(
      where: $where,
    ) {
      aggregate {
        count
      }
    }
    pokemon_v2_pokemon(
      limit: $limit,
      offset: $offset,
      order_by: $orderBy,
      where: $where,
    ) {
      name
      id
      base_experience
      pokemon_v2_pokemon…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Naramsim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant