Skip to content

Commit

Permalink
(temporarily?) remove queryRef.toPromise()
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas committed Jul 17, 2024
1 parent a6b0516 commit 0269f55
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
6 changes: 3 additions & 3 deletions integration-test/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
24 changes: 15 additions & 9 deletions packages/client-react-streaming/src/transportedQueryRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ export type TransportedQueryRefOptions = TransportedOptions &
export interface TransportedQueryRef<TData = unknown, TVariables = unknown>
extends QueryRef<TData, TVariables> {
/**
* 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<TransportedQueryRef>;
toPromise?: undefined;
}

export interface InternalTransportedQueryRef<
Expand All @@ -52,17 +51,24 @@ export interface InternalTransportedQueryRef<
export function createTransportedQueryRef<TData, TVariables>(
options: TransportedQueryRefOptions,
queryKey: string,
promise: Promise<any>
_promise: Promise<any>
): InternalTransportedQueryRef<TData, TVariables> {
const ref: InternalTransportedQueryRef<TData, TVariables> = {
__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;
}

Expand Down

0 comments on commit 0269f55

Please sign in to comment.