Inconsistency in the counts fields of the query connector

We are working on a gastronomic project, in Strapi of course. We got to the point that we needed to rely on count fields for certain functionalities and we thought to make them personalized.

Reading the documentation well and exploring, we find the query connectors that bring this functionality by default.

In practice and testing in the playground I have been able to identify a certain inconsistency that is not clear to me.

I have 1 account in the database.
I have 2 branches in the database.

My graphql query

query accountsConnection(
  $limit: Int
  $where: JSON
  $sort: String
  $start: Int
) {
  accountsConnection(
    limit: $limit
    where: $where
    sort: $sort
    start: $start
  ) {
    values {
      name
      slug
      verified
      countFollowers
      branches(limit: 1) {
        id
        location {
          city
          citySlug
        }
        featuredImage {
          url
        }
        avgRating
      }
    }
    aggregate {
      count
      totalCount
    }
  }
}

This query returns 1 result in the count, this is correct.

imagen

Now, if I add query parameters to filter the results, then the count field returns a value of 2 which should be impossible because there is only 1 account in the database and that is what I am querying.

Query parameters

{
  "where": {
    "branches":{"location": {"province": {"id_in": [2]}}}
  }
}

Result

Things got interesting when instead of sending him the province ID, he sent him the empty array.

Now it happens that it returns 1 account, but the count field returns zero. In theory it should not give me results because the sentence is not being fulfilled.

{
  "where": {
    "branches":{"location": {"province": {"id_in": []}}}
  }
}

Result
imagen

I have tried this last case with another environment and other data and I get the same behavior.

if do you want test it, check dev server

Thanks in advance for any support.

System Information
  • Strapi Version: v3.2.5
  • Operating System: Centos 7
  • Database: postgres:12.0
  • Node Version: v12.18.2
  • NPM Version: 6.14.5

@MattieBelt @DMehaffy some idea?

It has something to do with deep filtering, I’ve responded to the issue as I was able to reproduce it.

Workaround is implement the custom count into the GQL schema: Count with GraphQL - Strapi Developer Documentation