-
Notifications
You must be signed in to change notification settings - Fork 36
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
RSC preloading mechanism #258
Merged
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
c6119dd
ApolloClient: make browser event-replaying logic available in SSR
phryneas 08ba665
RSC preloading mechanism prototype
phryneas 047482c
fix build, update expected shape
phryneas a47cac9
remove console.log
phryneas e8057fc
progress
phryneas 293e03e
[WIP] queryRef
phryneas 50642e4
tests for both notations
phryneas fd7a7ed
fix up import
phryneas 558e52c
different resolutions
phryneas 8600cdc
test fixups
phryneas 3a014a4
integrate `useQueryRefHandlers`
phryneas 106e0c3
typings
phryneas 8ac604e
fix up test
phryneas eb0e41b
Merge remote-tracking branch 'origin/v0.11.0' into pr/rsc-preload
phryneas 750eecb
merge fixup
phryneas f9ea406
more fixup
phryneas e583479
refactor queryRef handling
phryneas 4051ae7
add test about referential assumptions
phryneas 6c54609
schema adjustments
phryneas f566049
bind `PreloadQuery` to `registerApolloClient`
phryneas 4e05fcb
move `getClient` into the promise chain
phryneas 4f65c0f
trigger CI
phryneas 66dffb5
adjust shape
phryneas 4eb91c7
update AC build
phryneas 54f3569
`gql(print(gql`
phryneas 5da45f9
pin types
phryneas 8f3e580
tweaks
phryneas 40d0651
udpate lockfile
phryneas eb063ab
forbid `nextFetchPolicy` in `PreloadQuery`
phryneas 0916027
fix up build, bump dep
phryneas 4615c72
use uuid, not useId
phryneas b0339ce
Merge branch 'main' into pr/rsc-preload
phryneas 1548891
update urls
phryneas 8591ba7
disable all kinds of minification
phryneas 902a598
change transport to events
phryneas c8a2ad5
simulate GraphQL error, not network error
phryneas 15311cf
use `query` in a test
phryneas 00585ea
undo disabling minification
phryneas 0cc5dec
add clarifying comment
phryneas 22b2924
Revert "simulate GraphQL error, not network error"
phryneas 56c0f3f
prevent unhandled promise rejections
phryneas 2177834
debugging
phryneas 7cb215c
Revert "undo disabling minification"
phryneas 3413d9b
test?
phryneas ab600e5
clean up debugging things
phryneas 0f59a31
Merge branch 'v0.11.0' into pr/rsc-preload
phryneas e10a769
update dependencies
phryneas 3af3000
more version pinning
phryneas 572f209
update lockfile even more
phryneas 902f673
also update `react-server-dom-webpack`
phryneas ba35077
adjust react version for vite-streaming
phryneas 2d454ff
TransportedQueryRef: inherit QueryReferenceBase
phryneas e64236d
split `TransportedQueryReference` type
phryneas e08acd9
queryOptions as props on `PreloadQuery`
phryneas 1e97538
Update packages/client-react-streaming/src/DataTransportAbstraction/W…
phryneas b162c52
adjust generic name and comment
phryneas 4735d7a
change to QueryRef base type
phryneas 50e1a7c
rename command to match parent project
phryneas 799a6a1
Merge branch 'v0.11.0' into pr/rsc-preload
phryneas 74c2fd2
update dependency "@apollo/client": "^3.10.4"
phryneas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
78 changes: 78 additions & 0 deletions
78
integration-test/nextjs/src/app/rsc/dynamic/PreloadQuery/PreloadQuery.test.ts
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,78 @@ | ||
import { expect } from "@playwright/test"; | ||
import { test } from "../../../../../fixture"; | ||
|
||
test.describe("PreloadQuery", () => { | ||
for (const [decription, path] of [ | ||
["with useSuspenseQuery", "useSuspenseQuery"], | ||
["with queryRef and useReadQuery", "queryRef-useReadQuery"], | ||
] as const) { | ||
test.describe(decription, () => { | ||
test("query resolves on the server", async ({ page, blockRequest }) => { | ||
await page.goto( | ||
`/rsc/dynamic/PreloadQuery/${path}?errorIn=ssr,browser`, | ||
{ | ||
waitUntil: "commit", | ||
} | ||
); | ||
|
||
await expect(page).toBeInitiallyLoading(true); | ||
await expect(page.getByText("loading")).not.toBeVisible(); | ||
await expect(page.getByText("Soft Warm Apollo Beanie")).toBeVisible(); | ||
await expect( | ||
page.getByText("Queried in RSC environment") | ||
).toBeVisible(); | ||
}); | ||
|
||
test("query errors on the server, restarts in the browser", async ({ | ||
page, | ||
}) => { | ||
page.allowErrors?.(); | ||
await page.goto(`/rsc/dynamic/PreloadQuery/${path}?errorIn=rsc`, { | ||
waitUntil: "commit", | ||
}); | ||
|
||
await expect(page).toBeInitiallyLoading(true); | ||
|
||
await page.waitForEvent("pageerror", (error) => { | ||
return ( | ||
/* prod */ error.message.includes("Minified React error #419") || | ||
/* dev */ error.message.includes("Query failed upstream.") | ||
); | ||
}); | ||
|
||
await expect(page.getByText("loading")).not.toBeVisible(); | ||
await expect(page.getByText("Soft Warm Apollo Beanie")).toBeVisible(); | ||
await expect( | ||
page.getByText("Queried in Browser environment") | ||
).toBeVisible(); | ||
}); | ||
}); | ||
} | ||
test("queryRef works with useQueryRefHandlers", async ({ page }) => { | ||
await page.goto(`/rsc/dynamic/PreloadQuery/queryRef-useReadQuery`, { | ||
waitUntil: "commit", | ||
}); | ||
|
||
await expect(page).toBeInitiallyLoading(true); | ||
await expect(page.getByText("loading")).not.toBeVisible(); | ||
await expect(page.getByText("Soft Warm Apollo Beanie")).toBeVisible(); | ||
await expect(page.getByText("Queried in RSC environment")).toBeVisible(); | ||
|
||
await page.getByRole("button", { name: "refetch" }).click(); | ||
await expect( | ||
page.getByText("Queried in Browser environment") | ||
).toBeVisible(); | ||
}); | ||
|
||
test("queryRef: assumptions about referential equality", async ({ page }) => { | ||
await page.goto(`/rsc/dynamic/PreloadQuery/queryRef-refTest`, { | ||
waitUntil: "commit", | ||
}); | ||
|
||
await page.getByRole("spinbutton").nth(11).waitFor(); | ||
|
||
for (let i = 0; i < 12; i++) { | ||
await expect(page.getByRole("spinbutton").nth(i)).toHaveClass("valid"); | ||
} | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just an additional guard to ensure this test never makes a query in the browser - not necessary but with the
error
context flag we now can do it :)