-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ApolloClient: make browser event-replaying logic available in SSR * RSC preloading mechanism prototype * fix build, update expected shape * remove console.log * progress * [WIP] queryRef * tests for both notations * fix up import * different resolutions * test fixups * integrate `useQueryRefHandlers` * typings * fix up test see apollographql/apollo-client#11772 * merge fixup * more fixup * refactor queryRef handling * add test about referential assumptions * schema adjustments * bind `PreloadQuery` to `registerApolloClient` * move `getClient` into the promise chain * trigger CI * adjust shape * update AC build * `gql(print(gql` * pin types * tweaks * udpate lockfile * forbid `nextFetchPolicy` in `PreloadQuery` * fix up build, bump dep * use uuid, not useId * update urls * disable all kinds of minification * change transport to events * simulate GraphQL error, not network error * use `query` in a test * undo disabling minification * add clarifying comment * Revert "simulate GraphQL error, not network error" This reverts commit c8a2ad5. * prevent unhandled promise rejections * debugging * Revert "undo disabling minification" This reverts commit 00585ea. * test? * clean up debugging things * update dependencies * more version pinning * update lockfile even more * also update `react-server-dom-webpack` * adjust react version for vite-streaming * TransportedQueryRef: inherit QueryReferenceBase * split `TransportedQueryReference` type * queryOptions as props on `PreloadQuery` * Update packages/client-react-streaming/src/DataTransportAbstraction/WrappedApolloClient.tsx Co-authored-by: Jerel Miller <jerelmiller@gmail.com> * adjust generic name and comment * change to QueryRef base type * rename command to match parent project * update dependency "@apollo/client": "^3.10.4" --------- Co-authored-by: Jerel Miller <jerelmiller@gmail.com>
- Loading branch information
1 parent
8856b72
commit cc189b8
Showing
50 changed files
with
1,227 additions
and
372 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
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.