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

Info received from hasNextPage is wrong in some resolvers #272

Open
MateoGuerreroE opened this issue Jun 14, 2024 · 5 comments
Open

Info received from hasNextPage is wrong in some resolvers #272

MateoGuerreroE opened this issue Jun 14, 2024 · 5 comments
Labels
bug Something isn't working more info needed

Comments

@MateoGuerreroE
Copy link

Describe the bug
When fetching data through a resolver we have that connects to a table with 4k+ records, It returns the data correctly, but for some reason returns hasNextPage: false when fetching more than (oddly specific) 373 records. Any number before that works normally, but If we try to fetch 373, 500, 1000 etc, It will state there are no more next pages. This happens in a single resolver of all we have exposed, but It is built exactly as other.

Have you read the Contributing Guidelines?

Yes

To Reproduce
Steps to reproduce the behavior:

  1. Fetch data through resolver and include paging: { first: ... } with a number above 372.
  2. Notice, It will return the hasNextPage: false even when the totalCount indicates the existence of more records.

Expected behavior
The hasNextPageattribute should show as true

Screenshots
image
image

Desktop (please complete the following information):

  • Node Version: 21.7.1
  • Nestjs-query Version: 6.1.0 (Tried with 6.1.1 and same thing happens)

Additional context
If I connect to a copy of the DB which has 1.8k records fetched on that same resolver, It works just perfect, so we tried to check If this has something to do with the number of records. Tried with some resolvers connected to tables that have +10k records and they work fine. Also, when trying to fetch next page using endCursor, It correctly returns next page, but still states hasNextPage as false, only says It's true on previous to last page.

@MateoGuerreroE MateoGuerreroE added the bug Something isn't working label Jun 14, 2024
@TriPSs
Copy link
Owner

TriPSs commented Jun 17, 2024

Which ORM are you using?

Notice, It will return the hasNextPage: false even when the totalCount indicates the existence of more records.

totalCount is not used for this, what it does it fetches n + 1, then it checks if the n is bigger then what the user provided, if yes hasNextPage will become true; this way there is no need for a additional query.

@MateoGuerreroE
Copy link
Author

MateoGuerreroE commented Jun 17, 2024

TypeORM & Postgre - Checked the executed SQL and as you mention If I set 373 It goes for LIMIT 374 and executing that SQL manually correctly gives 374 records (On the same example provided)

@TriPSs
Copy link
Owner

TriPSs commented Jun 17, 2024

Interesting, did you log the exact query TypeORM runs? (If you enable logging) And does that one return the correct results?

@MateoGuerreroE
Copy link
Author

Yes, I got two on the console, one for results and one SELECT COUNT(*) which should be for the totalCount, I executed them (copy-paste) manually using dbEaver and return that extra record normally. Weird enough: I just tested again using same resolver (same code) but another DB which reaches 10.9K records and works fine. I can't see how this could be related to the database.

@TriPSs
Copy link
Owner

TriPSs commented Jun 17, 2024

Interesting, using bigints maybe? I also can't think about anything that could cause this.

Think its also impossible to create a repo that reproduces this issue?

The output between the version that works and that does not work is also exactly the same? Maybe log this within the typeorm adapter to be sure.

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

No branches or pull requests

2 participants