-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat(nestjs-query): Add enableFetchAllWithNegative
option to allow to return all the items with -1
#87
Conversation
Hello @TriPSs I'm putting this PR in draft as it is not finished (I would have to handle the offset connection type and the backward pagination) I would like to check with you about what you were thinking about this implementation. Would you like me to create another field instead of reusing |
I think doing it with the -1 is a good one but I do think we need to do this behind a The main reason I think we need to put this behind a flag is that if someone uses this lib for a external API and the users of that API know that they can do a -1 to get everything that could then add un expected load on the API/database, what do you think? |
Yes, that is a good idea, in that way it would also prevent "breaking changes" (or changes in behavior) since the flag won't be on. I'll try to implement that ! |
2a685ed
to
a954f81
Compare
@TriPSs This PR should be good to be reviewed. In the end, I didn't nest the option in |
enableFetchAllWithNegative
option to allow to return all the items with -1
Nice! Can you check the tests? |
4867804
to
62eb9c3
Compare
62eb9c3
to
7f8913f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #87 +/- ##
==========================================
+ Coverage 86.22% 86.36% +0.13%
==========================================
Files 688 697 +9
Lines 9765 9849 +84
Branches 864 876 +12
==========================================
+ Hits 8420 8506 +86
+ Misses 624 619 -5
- Partials 721 724 +3 ☔ View full report in Codecov by Sentry. |
@TriPSs
It looks like I'm missing a set up somewhere, would you have an idea? |
I actually already created That's why I'm a bit confused |
Where do you get that error? If i check the actions i see the following one:
|
@TriPSs Sorry for the late reply, I got busy, it seems like MySQL doesn't support
What do you think we could do about that?
Or any other idea? |
@TriPSs Would you have any advice on this one? |
We could to number 4 if the feature is enabled? Only not quite sure what "big number" we should use. |
…urn-all-the-items-even-when-paginated # Conflicts: # packages/query-graphql/src/types/connection/cursor/pager/strategies/keyset.pager-strategy.ts
☁️ Nx Cloud ReportCI is running/has finished running commands for commit ff0e245. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 5 targetsSent with 💌 from NxCloud. |
@TriPSs I set the limit to I had to implement it in Tell me if you have a better design in mind or if you prefer to fall back to
|
Let's indeed do this, if we eventually get tickets that ppl also need it in MySQL we can also revisit it. |
@@ -70,11 +78,12 @@ export class LimitOffsetPagerStrategy<DTO> implements PagerStrategy<DTO> { | |||
} | |||
return last | |||
} | |||
return cursor.first || 0 | |||
return cursor.first ?? 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it's good to keep ||
here, or was there a specific reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just that cursor.first
is a ?: number
so the only values possible are undefined
, 0
, and any number above 0. The ??
operator is made for this use case (handle null
and undefined
only) while 0
will also "ignore" 0
. So I felt it was "more correct" to use ??
rather than ||
.
I don't mind reverting and using ||
if you prefer to
This reverts commit 9bfe290. # Conflicts: # packages/query-typeorm/src/services/typeorm-query.service.ts
@TriPSs I reverted the changes made in |
My longest contribution ever 😄 |
Fixes #63
Querying the todo items from the example
returns the entire list.