From 0269f55a37f13c128e64bb960980835e45b261d1 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Wed, 17 Jul 2024 15:51:35 +0200 Subject: [PATCH] (temporarily?) remove `queryRef.toPromise()` --- integration-test/yarn.lock | 6 ++--- .../src/transportedQueryRef.ts | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/integration-test/yarn.lock b/integration-test/yarn.lock index 5b8f3a89..20e8c3ea 100644 --- a/integration-test/yarn.lock +++ b/integration-test/yarn.lock @@ -32,7 +32,7 @@ __metadata: linkType: hard "@apollo/client-react-streaming@exec:./shared/build-client-react-streaming.cjs::locator=%40integration-test%2Froot%40workspace%3A.": - version: 0.11.0 + version: 0.11.1 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: ts-invariant: "npm:^0.10.3" @@ -81,10 +81,10 @@ __metadata: linkType: hard "@apollo/experimental-nextjs-app-support@exec:./shared/build-experimental-nextjs-app-support.cjs::locator=%40integration-test%2Froot%40workspace%3A.": - version: 0.11.0 + version: 0.11.1 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.11.0" + "@apollo/client-react-streaming": "npm:0.11.1" peerDependencies: "@apollo/client": ^3.10.4 next: ^13.4.1 || ^14.0.0 || 15.0.0-rc.0 diff --git a/packages/client-react-streaming/src/transportedQueryRef.ts b/packages/client-react-streaming/src/transportedQueryRef.ts index 85cebf4c..5100df2b 100644 --- a/packages/client-react-streaming/src/transportedQueryRef.ts +++ b/packages/client-react-streaming/src/transportedQueryRef.ts @@ -32,12 +32,11 @@ export type TransportedQueryRefOptions = TransportedOptions & export interface TransportedQueryRef extends QueryRef { /** - * Only available in React Server Components. - * Will be `undefined` after being passed to Client Components. + * Temporarily disabled - see https://github.com/apollographql/apollo-client-nextjs/issues/332 * - * Returns a promise that resolves back to the `TransportedQueryRef` that can be awaited in RSC to suspend a subtree until the originating query has been loaded. + * Will now be be `undefined` both in React Server Components and Client Components until we can find a better resolution. */ - toPromise?: () => Promise; + toPromise?: undefined; } export interface InternalTransportedQueryRef< @@ -52,17 +51,24 @@ export interface InternalTransportedQueryRef< export function createTransportedQueryRef( options: TransportedQueryRefOptions, queryKey: string, - promise: Promise + _promise: Promise ): InternalTransportedQueryRef { const ref: InternalTransportedQueryRef = { __transportedQueryRef: true, options, queryKey, }; - Object.defineProperty(ref, "toPromise", { - value: () => promise.then(() => ref), - enumerable: false, - }); + /* + Temporarily disabled - see https://github.com/apollographql/apollo-client-nextjs/issues/332 + This causes a dev-mode warning: + Warning: Only plain objects can be passed to Client Components from Server Components. Classes or other objects with methods are not supported. + <... queryRef={{__transportedQueryRef: true, options: ..., queryKey: ...}}> + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + */ + // Object.defineProperty(ref, "toPromise", { + // value: () => promise.then(() => ref), + // enumerable: false, + // }); return ref; }