Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(temporarily?) remove queryRef.toPromise() #333

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2
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.2
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.2"
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
Loading