Implement query variables in useCombinedFindManyRecords (#10015)

Implements filtering, ordering and cursor filtering for the hook
useCombinedFindManyRecords, because it was not implemented, which was
misleading because variables could be passed to it.

The difficult part was to make sure that the cursor filtering was
working, both before and after a cursor, because it was only hard coded
for last cursor (equivalent to after).

The duplicate limit parameter in the type RecordGqlOperationVariables
was merged into one limit parameter, because it was making the developer
guess how both could be handled.

This single limit parameter can be used for either : general limit
without cursor, first records from after cursor, last records until
before cursor. Since those cases are exclusive it's better to have only
one limit parameter and have an internal logic handling those cases.

Tests were added on the relevant parts, especially
useCombinedFindManyRecordsQueryVariables which requires its own unit
test to handle this cursor + limit logic.

Record show page pagination was tested to make sure removing the
duplicate limit parameter had no impact.
This commit is contained in:
Lucas Bordeau
2025-02-05 11:59:38 +01:00
committed by GitHub
parent 28a3f75946
commit 074cc113ac
9 changed files with 877 additions and 26 deletions

View File

@ -9,6 +9,5 @@ export type RecordGqlOperationVariables = {
cursorFilter?: {
cursor: string;
cursorDirection: QueryCursorDirection;
limit: number;
};
};