-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Seppe Dekeyser <[email protected]>
- Loading branch information
1 parent
41307a2
commit 2cf22c7
Showing
22 changed files
with
443 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'houdini-svelte': patch | ||
'houdini-react': patch | ||
'houdini': patch | ||
--- | ||
|
||
Add @dedupe directive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
query DedupePaginationFetch { | ||
usersConnection(first: 2, delay: 1000, snapshot: "dedupe-pagination-fetch") @paginate { | ||
pageInfo { | ||
hasNextPage | ||
hasPreviousPage | ||
startCursor | ||
endCursor | ||
} | ||
edges { | ||
node { | ||
name | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { PageProps } from './$types' | ||
|
||
export default function ({ DedupePaginationFetch, DedupePaginationFetch$handle }: PageProps) { | ||
return ( | ||
<div> | ||
<div id="result"> | ||
{DedupePaginationFetch.usersConnection.edges | ||
.map(({ node }) => node?.name) | ||
.join(', ')} | ||
</div> | ||
|
||
<div id="pageInfo"> | ||
{JSON.stringify(DedupePaginationFetch.usersConnection.pageInfo)} | ||
</div> | ||
|
||
<button id="next" onClick={() => DedupePaginationFetch$handle.loadNext()}> | ||
next | ||
</button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import test, { expect, type Response } from '@playwright/test' | ||
import { routes } from '~/utils/routes' | ||
import { expect_1_gql, expect_to_be, goto } from '~/utils/testsHelper' | ||
|
||
test('pagination before previous request was finished', async ({ page }) => { | ||
await goto(page, routes.pagination_dedupe) | ||
|
||
await expect_to_be(page, 'Bruce Willis, Samuel Jackson') | ||
|
||
// Adapted from `expect_n_gql` in lib/utils/testsHelper.ts | ||
let nbResponses = 0 | ||
async function fnRes(response: Response) { | ||
if (response.url().endsWith(routes.api)) { | ||
nbResponses++ | ||
} | ||
} | ||
|
||
page.on('response', fnRes) | ||
|
||
// Click the "next page" button twice | ||
await page.click('button[id=next]') | ||
await page.click('button[id=next]') | ||
|
||
// Give the query some time to execute | ||
await page.waitForTimeout(1000) | ||
|
||
// Check that only one gql request happened. | ||
expect(nbResponses).toBe(1) | ||
|
||
page.removeListener('response', fnRes) | ||
|
||
await expect_to_be(page, 'Bruce Willis, Samuel Jackson, Morgan Freeman, Tom Hanks') | ||
|
||
// Fetching the 3rd page still works ok. | ||
await expect_1_gql(page, 'button[id=next]') | ||
await expect_to_be( | ||
page, | ||
'Bruce Willis, Samuel Jackson, Morgan Freeman, Tom Hanks, Will Smith, Harrison Ford' | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.