diff --git a/.github/workflows/pkg-pr-new-publish.yml b/.github/workflows/pkg-pr-new-publish.yml new file mode 100644 index 00000000..856b6486 --- /dev/null +++ b/.github/workflows/pkg-pr-new-publish.yml @@ -0,0 +1,32 @@ +name: pkg-pr-new Publish + +on: + pull_request: + push: + branches: + - "**" + tags: + - "!**" + +jobs: + prerelease: + name: pkg-pr-new Publish + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Node.js 20.x + uses: actions/setup-node@v4 + with: + node-version: 20.x + cache: yarn + + - name: Install dependencies + run: yarn install + + - name: Prebuild libs + run: yarn build:libs + + - name: Build and publish to pkg.pr.new + run: yarn dlx pkg-pr-new publish --no-template packages/client-react-streaming packages/experimental-nextjs-app-support diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 66eea798..0bbcc6b1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -123,7 +123,7 @@ jobs: # Upload webpack-stats.json to use on relative-ci.yaml workflow - name: Upload webpack stats artifact if: matrix.version == 'latest' - uses: relative-ci/agent-upload-artifact-action@v1 + uses: relative-ci/agent-upload-artifact-action@v2 with: webpackStatsFile: ./integration-test/nextjs/webpack-stats.json diff --git a/packages/client-react-streaming/src/ManualDataTransport/ApolloRehydrateSymbols.tsx b/packages/client-react-streaming/src/ManualDataTransport/ApolloRehydrateSymbols.tsx index b1486440..206664a8 100644 --- a/packages/client-react-streaming/src/ManualDataTransport/ApolloRehydrateSymbols.tsx +++ b/packages/client-react-streaming/src/ManualDataTransport/ApolloRehydrateSymbols.tsx @@ -1,10 +1,16 @@ import type { DataTransport } from "./dataTransport.js"; +import type { RehydrationCache } from "./types.js"; declare global { interface Window { [ApolloSSRDataTransport]?: DataTransport; + [ApolloHookRehydrationCache]?: RehydrationCache; } } export const ApolloSSRDataTransport = /*#__PURE__*/ Symbol.for( "ApolloSSRDataTransport" ); + +export const ApolloHookRehydrationCache = /*#__PURE__*/ Symbol.for( + "apollo.hookRehydrationCache" +); diff --git a/packages/client-react-streaming/src/ManualDataTransport/ManualDataTransport.tsx b/packages/client-react-streaming/src/ManualDataTransport/ManualDataTransport.tsx index 6900e6db..e20f8cd1 100644 --- a/packages/client-react-streaming/src/ManualDataTransport/ManualDataTransport.tsx +++ b/packages/client-react-streaming/src/ManualDataTransport/ManualDataTransport.tsx @@ -6,6 +6,7 @@ import type { HydrationContextOptions } from "./RehydrationContext.js"; import { buildApolloRehydrationContext } from "./RehydrationContext.js"; import { registerDataTransport } from "./dataTransport.js"; import { revive, stringify } from "./serialization.js"; +import { ApolloHookRehydrationCache } from "./ApolloRehydrateSymbols.js"; export interface ManualDataTransportOptions { /** @@ -81,7 +82,9 @@ const buildManualDataTransportBrowserImpl = ({ onQueryEvent, rerunSimulatedQueries, }) { - const hookRehydrationCache = useRef({}); + const hookRehydrationCache = useRef( + (window[ApolloHookRehydrationCache] ??= {}) + ); registerDataTransport({ onQueryEvent: onQueryEvent!, onRehydrate(rehydrate) { diff --git a/packages/client-react-streaming/src/ManualDataTransport/index.ts b/packages/client-react-streaming/src/ManualDataTransport/index.ts index 673a7df1..23dfb498 100644 --- a/packages/client-react-streaming/src/ManualDataTransport/index.ts +++ b/packages/client-react-streaming/src/ManualDataTransport/index.ts @@ -2,7 +2,10 @@ export { buildManualDataTransport } from "./ManualDataTransport.js"; export type { HydrationContextOptions } from "./RehydrationContext.js"; -import { ApolloSSRDataTransport } from "./ApolloRehydrateSymbols.js"; +import { + ApolloHookRehydrationCache, + ApolloSSRDataTransport, +} from "./ApolloRehydrateSymbols.js"; import { resetApolloSingletons } from "@apollo/client-react-streaming"; /** @@ -19,5 +22,6 @@ import { resetApolloSingletons } from "@apollo/client-react-streaming"; */ export function resetManualSSRApolloSingletons() { resetApolloSingletons(); + delete window[ApolloHookRehydrationCache]; delete window[ApolloSSRDataTransport]; }