Skip to content

Commit

Permalink
Merge branch 'main' into pr/warn-on-useless-options
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Oct 21, 2024
2 parents f63daf0 + e6bfd3a commit 197ba3e
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 3 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pkg-pr-new-publish.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import type { DataTransport } from "./dataTransport.js";
import type { RehydrationCache } from "./types.js";

declare global {
interface Window {
[ApolloSSRDataTransport]?: DataTransport<unknown>;
[ApolloHookRehydrationCache]?: RehydrationCache;
}
}
export const ApolloSSRDataTransport = /*#__PURE__*/ Symbol.for(
"ApolloSSRDataTransport"
);

export const ApolloHookRehydrationCache = /*#__PURE__*/ Symbol.for(
"apollo.hookRehydrationCache"
);
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -81,7 +82,9 @@ const buildManualDataTransportBrowserImpl = ({
onQueryEvent,
rerunSimulatedQueries,
}) {
const hookRehydrationCache = useRef<RehydrationCache>({});
const hookRehydrationCache = useRef<RehydrationCache>(
(window[ApolloHookRehydrationCache] ??= {})
);
registerDataTransport({
onQueryEvent: onQueryEvent!,
onRehydrate(rehydrate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

/**
Expand All @@ -19,5 +22,6 @@ import { resetApolloSingletons } from "@apollo/client-react-streaming";
*/
export function resetManualSSRApolloSingletons() {
resetApolloSingletons();
delete window[ApolloHookRehydrationCache];
delete window[ApolloSSRDataTransport];
}

0 comments on commit 197ba3e

Please sign in to comment.