Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor ignored during pagination #381

Closed
adzialocha opened this issue May 18, 2023 · 2 comments · Fixed by #412
Closed

Cursor ignored during pagination #381

adzialocha opened this issue May 18, 2023 · 2 comments · Fixed by #412
Labels
bug Something isn't working

Comments

@adzialocha
Copy link
Member

Request 1:

{
  messages: all_chat_message_002055f4d34a8dd861270a0ebcb111acd1996ceda283dab1d0c09e59d5414e43a83f(
    orderBy: "timestamp"
    orderDirection: ASC
  ) {
    hasNextPage
    endCursor
    documents {
      cursor
      fields {
        text
        timestamp
      }
    }
  }
}

Result 1:

{
  "data": {
    "messages": {
      "hasNextPage": false,
      "endCursor": "33W9ydxf9SqZu3exkdHY9KZTkzYTk6WtCSHVbQxhcBYSS6GaBGgBQRdKfVzaKnsxUudM6R2yHCiarVGn9a3cGEsA",
      "documents": [
        {
          "cursor": "21Ca22qpjQkowN8X6sGusJKtMR8p8sQvYh7VMpFmwgdwf5ePVxzGPUVTc82k81dfcU2doWoDRAbSEpxDQGxuH89B",
          "fields": {
            "text": "1",
            "timestamp": 1684403519921
          }
        },
        {
          "cursor": "33W9ydxf9SqZu3exkdHY9KZTkzYTk6WtCSHVbQxhcBYSS6GaBGgBQRdKfVzaKnsxUudM6R2yHCiarVGn9a3cGEsA",
          "fields": {
            "text": "2",
            "timestamp": 1684403544448
          }
        }
      ]
    }
  }
}

Request 2 (using cursor of the last document in after):

{
  messages: all_chat_message_002055f4d34a8dd861270a0ebcb111acd1996ceda283dab1d0c09e59d5414e43a83f(
    after: "33W9ydxf9SqZu3exkdHY9KZTkzYTk6WtCSHVbQxhcBYSS6GaBGgBQRdKfVzaKnsxUudM6R2yHCiarVGn9a3cGEsA"
    orderBy: "timestamp"
    orderDirection: ASC
  ) {
    hasNextPage
    endCursor
    documents {
      cursor
      fields {
        text
        timestamp
      }
    }
  }
}

Result 2: Same as above, but should have been empty page.

@adzialocha adzialocha added the bug Something isn't working label May 18, 2023
@adzialocha adzialocha changed the title Cursor gets ignored during pagination Cursor ignored during pagination May 18, 2023
@adzialocha
Copy link
Member Author

Result 2: Same as above, but should have been empty page.

The pagination works as expected when the query is not ordered by timestamp.

@adzialocha
Copy link
Member Author

Another weird thing I'm observing is that the cursor changes when setting first to a lower number:

{
  messages: all_chat_message_002055f4d34a8dd861270a0ebcb111acd1996ceda283dab1d0c09e59d5414e43a83f(
    first: 1
  ) {
    hasNextPage
    endCursor
    documents {
      cursor
      fields {
        text
        timestamp
      }
    }
  }
}
{
  "data": {
    "messages": {
      "hasNextPage": true,
      "endCursor": "24gsNAQQFPnEjLRNSuQiDRSy5Zex4AKfRT2cfCCfzWXsPGzLaA9yF1BaKyPFTBS4dM7LkC95nribvpugH9dcnL92",
      "documents": [
        {
          "cursor": "24gsNAQQFPnEjLRNSuQiDRSy5Zex4AKfRT2cfCCfzWXsPGzLaA9yF1BaKyPFTBS4dM7LkC95nribvpugH9dcnL92",
          "fields": {
            "text": "1",
            "timestamp": 1684403519921
          }
        }
      ]
    }
  }
}

Note how it is now 24gsNA... while it was 21Ca22... before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant