Skip to content

Commit 514c38f

Browse files
Fix pagination in mock drivers to use offset instead of skip
Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent 0708f0c commit 514c38f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

packages/runtime/server/test/graphql.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ class MockDriver implements Driver {
4343
async find(objectName: string, query: any) {
4444
let items = this.data[objectName] || [];
4545

46-
// Apply skip and limit if provided
46+
// Apply offset and limit if provided (QueryAST uses 'offset', not 'skip')
4747
if (query) {
48-
if (query.skip) {
49-
items = items.slice(query.skip);
48+
if (query.offset) {
49+
items = items.slice(query.offset);
5050
}
5151
if (query.limit) {
5252
items = items.slice(0, query.limit);

packages/runtime/server/test/rest-advanced.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class MockDriver implements Driver {
4141
}
4242
}
4343

44-
// Apply skip and top/limit (QueryAST uses 'top' for limit)
45-
if (query?.skip) {
46-
items = items.slice(query.skip);
44+
// Apply offset and limit (QueryAST uses 'offset' for skip)
45+
if (query?.offset) {
46+
items = items.slice(query.offset);
4747
}
4848
if (query?.top || query?.limit) {
4949
items = items.slice(0, query.top || query.limit);
@@ -87,8 +87,9 @@ class MockDriver implements Driver {
8787
}
8888

8989
async count(objectName: string, query: any) {
90-
// Count should not apply skip/limit, only filters
90+
// Count should not apply offset/limit, only filters
9191
const countQuery = { ...query };
92+
delete countQuery.offset;
9293
delete countQuery.skip;
9394
delete countQuery.top;
9495
delete countQuery.limit;

0 commit comments

Comments
 (0)