diff --git a/integration-test/yarn.lock b/integration-test/yarn.lock index 22b18208..394149b9 100644 --- a/integration-test/yarn.lock +++ b/integration-test/yarn.lock @@ -32,13 +32,13 @@ __metadata: linkType: hard "@apollo/client-react-streaming@exec:./shared/build-client-react-streaming.cjs::locator=%40integration-test%2Froot%40workspace%3A.": - version: 0.8.0 + version: 0.10.0 resolution: "@apollo/client-react-streaming@exec:./shared/build-client-react-streaming.cjs#./shared/build-client-react-streaming.cjs::hash=48b117&locator=%40integration-test%2Froot%40workspace%3A." dependencies: superjson: "npm:^1.12.2 || ^2.0.0" ts-invariant: "npm:^0.10.3" peerDependencies: - "@apollo/client": ^3.9.0 + "@apollo/client": ^3.9.6 react: ^18 checksum: 10/8e12155ebcb9672f5b645c364d356018014df750412c61613341121ebb4d4eabb5f42cd9018cc3a81ad988f1b425548d68254ca49ede19c31d0d9e5a9a4f240a languageName: node @@ -82,12 +82,12 @@ __metadata: linkType: hard "@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs::locator=%40integration-test%2Froot%40workspace%3A.": - version: 0.8.0 + version: 0.10.0 resolution: "@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs#./shared/build-experimental-nextjs-app-support.cjs::hash=fd83cc&locator=%40integration-test%2Froot%40workspace%3A." dependencies: - "@apollo/client-react-streaming": "npm:^0.9.0" + "@apollo/client-react-streaming": "npm:0.10.0" peerDependencies: - "@apollo/client": ^3.9.0 + "@apollo/client": ^3.9.6 next: ^13.4.1 || ^14.0.0 react: ^18 checksum: 10/505b723bac0f3a7f15287ea32fab9f2e8c0cd567149abf11d750855f8a9bfc0aa26e44179ad10c32f7d162ad86318717032413ef8e1a25385185178e022588fa diff --git a/packages/experimental-nextjs-app-support/src/ApolloNextAppProvider.ts b/packages/experimental-nextjs-app-support/src/ApolloNextAppProvider.ts index f9dd1d1f..1679ed87 100644 --- a/packages/experimental-nextjs-app-support/src/ApolloNextAppProvider.ts +++ b/packages/experimental-nextjs-app-support/src/ApolloNextAppProvider.ts @@ -46,8 +46,13 @@ export const ApolloNextAppProvider = /*#__PURE__*/ WrapApolloProvider( useInsertHtml() { const insertHtml = useContext(ServerInsertedHTMLContext); if (!insertHtml) { + if (process.env.REACT_ENV === "browser") { + //Allow using the browser build of ApolloNextAppProvider outside of Next.js, e.g. for tests. + return () => {}; + } throw new Error( - "ApolloNextAppProvider cannot be used outside of the Next App Router!" + "The SSR build of ApolloNextAppProvider cannot be used outside of the Next App Router!\n" + + 'If you encounter this in a test, make sure that your tests are using the browser build by adding the "browser" import condition to your test setup.' ); } return insertHtml;