Skip to content

Commit

Permalink
Remove alpha designation for query preloading (#11743)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller authored Apr 2, 2024
1 parent 363d21e commit 78891f9
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .api-reports/api-report-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ type ConcastSourcesIterable<T> = Iterable<Source<T>>;
export interface Context extends Record<string, any> {
}

// @alpha
// @public
export function createQueryPreloader(client: ApolloClient<any>): PreloadQueryFunction;

// @public (undocumented)
Expand Down Expand Up @@ -1757,7 +1757,6 @@ export interface QueryReference<TData = unknown, TVariables = unknown> {
//
// @internal (undocumented)
readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
// @alpha
toPromise(): Promise<QueryReference<TData, TVariables>>;
}

Expand Down
1 change: 0 additions & 1 deletion .api-reports/api-report-react_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -1632,7 +1632,6 @@ interface QueryReference<TData = unknown, TVariables = unknown> {
//
// @internal (undocumented)
readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
// @alpha
toPromise(): Promise<QueryReference<TData, TVariables>>;
}

Expand Down
1 change: 0 additions & 1 deletion .api-reports/api-report-react_internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,6 @@ export interface QueryReference<TData = unknown, TVariables = unknown> {
[PROMISE_SYMBOL]: QueryRefPromise<TData>;
// @internal (undocumented)
readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
// @alpha
toPromise(): Promise<QueryReference<TData, TVariables>>;
}

Expand Down
3 changes: 1 addition & 2 deletions .api-reports/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ export const concat: typeof ApolloLink.concat;
// @public (undocumented)
export const createHttpLink: (linkOptions?: HttpOptions) => ApolloLink;

// @alpha
// @public
export function createQueryPreloader(client: ApolloClient<any>): PreloadQueryFunction;

// @public @deprecated (undocumented)
Expand Down Expand Up @@ -2330,7 +2330,6 @@ export interface QueryReference<TData = unknown, TVariables = unknown> {
//
// @internal (undocumented)
readonly [QUERY_REFERENCE_SYMBOL]: InternalQueryReference<TData>;
// @alpha
toPromise(): Promise<QueryReference<TData, TVariables>>;
}

Expand Down
5 changes: 5 additions & 0 deletions .changeset/tiny-bugs-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": minor
---

Remove alpha designation for `queryRef.toPromise()` to stabilize the API.
5 changes: 5 additions & 0 deletions .changeset/twelve-apples-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": minor
---

Remove alpha designation for `createQueryPreloader` to stabilize the API.
12 changes: 0 additions & 12 deletions docs/source/data/suspense.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,6 @@ We begin fetching our `GET_DOG_QUERY` by calling the `loadDog` function inside o

</MinVersion>

<ExperimentalFeature>

This feature is in [alpha](https://www.apollographql.com/docs/resources/product-launch-stages/#alpha--beta) in version `3.9.0` and is subject to change before `3.10.0`. We consider this feature production-ready, but it may change depending on feedback. If you'd like to provide feedback before it is stabilized in `3.10.0`, please comment on [#11519](https://github.com/apollographql/apollo-client/issues/11519).

</ExperimentalFeature>

Starting with Apollo Client `3.9.0`, queries can be initiated outside of React. This allows your app to begin fetching data before React renders your components, and can provide performance benefits.

To preload queries, you first need to create a preload function with `createQueryPreloader`. `createQueryPreloader` takes an `ApolloClient` instance as an argument and returns a function that, when called, initiates a network request.
Expand Down Expand Up @@ -677,12 +671,6 @@ export function RouteComponent() {

This instructs React Router to wait for the query to finish loading before the route transitions. When the route transitions after the promise resolves, the data is rendered immediately without the need to show a loading fallback in the route component.

<ExperimentalFeature>

`queryRef.toPromise` is [experimental](https://www.apollographql.com/docs/resources/product-launch-stages/#experimental-features) in version `3.9.0` and is subject to breaking changes before `3.10.0`. If you'd like to provide feedback for this feature before it is stabilized in `3.10.0`, please comment on [#11519](https://github.com/apollographql/apollo-client/issues/11519).

</ExperimentalFeature>

#### Why prevent access to `data` in `toPromise`?

You may be wondering why we resolve `toPromise` with the `queryRef` itself, rather than the data loaded from the query. We want to encourage you to leverage `useReadQuery` to avoid missing out on cache updates for your query. If `data` were available, it would be tempting to consume it in your `loader` functions and expose it to your route components. Doing so means missing out on cache updates.
Expand Down
2 changes: 1 addition & 1 deletion src/react/internal/cache/QueryReference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export interface QueryReference<TData = unknown, TVariables = unknown> {
* }
* ```
*
* @alpha
* @since 3.9.0
*/
toPromise(): Promise<QueryReference<TData, TVariables>>;
}
Expand Down
1 change: 0 additions & 1 deletion src/react/query-preloader/createQueryPreloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export interface PreloadQueryFunction {
* const preloadQuery = createQueryPreloader(client);
* ```
* @since 3.9.0
* @alpha
*/
export function createQueryPreloader(
client: ApolloClient<any>
Expand Down

0 comments on commit 78891f9

Please sign in to comment.