Prisma1: Aggregate count not work as expected with pagination

Created on 3 Oct 2018  路  3Comments  路  Source: prisma/prisma1

Describe the bug
Aggregation count not working as expected: when you try to list an entity using generated query from Prisma with pagination (eg. skip + first parameters), count returns exactly the first parameter or lower number corresponding to the number of remaining items.

To Reproduce
Steps to reproduce the behavior:

query {
  listMyEntity (skip: 0, first: 20) {
    aggregate {
      count
    }
  }
}

count result is at most 20, even if I have 100000 elements.

Expected behavior
I would like to obtain the total number of items, as the previous versions of prisma worked.

Versions (please complete the following information):

  • OS: [Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-1061-aws x86_64)]
  • prisma CLI: [prisma/1.7.1 (darwin-x64) node-v10.4.0]
  • prisma: 1.17.1, prisma-binding: 2.1.6, graphql-yoga: 1.16.2

Most helpful comment

@marktani - If the Prisma team is sticking with this decision, could you help out here? https://www.prisma.io/forum/t/how-to-get-a-full-aggregate-for-a-connection-using-prisma-bindings/5698

Furthermore, what is the reasoning behind this change? Besides being able to just .length on the edges that is returned on a list to get that value, I would expect something like that to just live on a PageInfo object or the likes. As a developer using the Prisma API, I exepct aggregate.count to return the full list length for the query I'm performing.

TL;DR - How can you get the "real" aggregate count when using prisma-binding, passing the user's info object to your Prisma query?

All 3 comments

This is the expected behaviour. The previous behaviour was not intended and recently fixed. You can query the full count and the filtered count in one request like so:

query {
  listMyEntity (skip: 0, first: 20) {
    aggregate {
      count
    }
  }
  full: listMyEntity {
    aggregate {
      count
    }
  }
}

@marktani - If the Prisma team is sticking with this decision, could you help out here? https://www.prisma.io/forum/t/how-to-get-a-full-aggregate-for-a-connection-using-prisma-bindings/5698

Furthermore, what is the reasoning behind this change? Besides being able to just .length on the edges that is returned on a list to get that value, I would expect something like that to just live on a PageInfo object or the likes. As a developer using the Prisma API, I exepct aggregate.count to return the full list length for the query I'm performing.

TL;DR - How can you get the "real" aggregate count when using prisma-binding, passing the user's info object to your Prisma query?

I have the same problem here

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jannone picture jannone  路  3Comments

akoenig picture akoenig  路  3Comments

hoodsy picture hoodsy  路  3Comments

ragnorc picture ragnorc  路  3Comments

nikolasburk picture nikolasburk  路  3Comments