ChilliCream / graphql-platform

Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Banana Cake Pop the awesome Monaco based GraphQL IDE.
https://chillicream.com
MIT License
5.26k stars 746 forks source link

totalCount seems to be wrong when using UseMongoDbPaging #3868

Closed jprubio closed 3 years ago

jprubio commented 3 years ago

Describe the bug Hi everyone,

when i use UseMongoDbPaging with IncludeTotalCount=true , the totalCount field seems to be wrong when 'first' field is included in query.

To Reproduce On MongoDB example (https://github.com/ChilliCream/hotchocolate-examples/tree/master/misc/MongoDB) ... When I write following query

{
  persons(where: { name: { contains: "Romeo" } }) {
    totalCount
    nodes {
      name
    }
  }
}

throws right number of items and totalCount (3):

{
  "data": {
    "persons": {
      "totalCount": 3,
      "nodes": [
        {
          "name": "Romeo McCloy"
        },
        {
          "name": "Romeo2 McCloy"
        },
        {
          "name": "Romeo3 McCloy"
        }
      ]
    }
  }
}

But when i include 'first' value, totalCount differs:

{
  persons(first:1, where: { name: { contains: "Romeo" } }) {
    totalCount
    nodes {
      name
    }
  }
}
{
  "data": {
    "persons": {
      "totalCount": 2,
      "nodes": [
        {
          "name": "Romeo McCloy"
        }
      ]
    }
  }
}

Expected behavior totalCount should show always the total number of elements that matches the input filter, in above case, 3.

Additional context Faced with HC 11.3 and also HC 12.0.0-preview.18

PascalSenn commented 3 years ago

did you try this with 11.3? we reworked paging completly

jprubio commented 3 years ago

did you try this with 11.3? we reworked paging completly

Sure, 11.3 and also 12.0.0-preview.18

tobias-tengler commented 3 years ago

I think there's a general flaw in the MongoDB pagination logic, since #3683 talks about the same issue, but for MongoDbOffsetPaging.

michaelstaib commented 3 years ago

@PascalSenn I put both paging bugs on your deck for V12 since we need this to be working for our ccc project.