🐞 BUG: orderBy Int type in connection query sorts by only the indifferent values!


Here’s what the bug is, and how you can reproduce the same!
As per Order by Related Fields issue, users yet cannot sort postsConnection by orderBy: upvotes_DESC when this is the schema :point_down:

type Post {
  id: ID!
  upvotes: [Upvote]!

So, I created upvotesNumber field which accepts an Int. Every time I mutate an upvote from backend, I increment or decrement the field.

But to sort postsConnection by upvotesNumber, the orderBy introduces a severe bug.

query {
  postsConnection (
    orderBy: upvotesNumber_DESC, 
    first: 1
  ) {
    edges {
      node {
    pageInfo {

Suppose I have 3 posts. 1st post has 2 upvotes, i.e upvotesNumber: 2, 2nd post has 1 upvote, and the third post has 0 upvotes.

In this case, I get the correct postsConnection order and all three posts are fetched using the after argument.

But, if two or more than two posts have the same upvotesNumber value, then those posts won’t render in postsConnection!

Consider, 1st post has 1 upvote, 2nd post also has 1 upvote, third has none…
then the same query will return return 1st and 3rd post but will skip the 2nd even if I use the correct after value that endCursor gives.

Same happens when 2nd and 3rd posts have 0 upvotes and 1st post has 1. Then, the query will return 1st and 2nd post, but would skip the three.

Expected behavior
I expect it to render all posts correctly just as it renders when I order it by createdAt_DESC.
createdAt_DESC works very well. I want to sort the posts by upvotesNumber even if they are the same!

Versions (please complete the following information):

  • Prisma Server: v1.26.0
  • prisma CLI: prisma/1.26.4 (darwin-x64) node-v11.4.0
  • OS: OSX Mojave
  • other dependencies: prisma-client, prisma-binding, etc.

Additional context
This makes me unable to use Prisma. I’m a novice. This might be the way how Prisma works or I might be doing it wrong. Please help :pray:

Resources I read before posting this bug report
Order by Multiple Fields
Order by Related Fields
Load More on Upvote bug