Skip to content

Commit

Permalink
move createQueryPreloader example (#11613)
Browse files Browse the repository at this point in the history
  • Loading branch information
koenpunt committed Feb 20, 2024
1 parent 19f2efc commit aa7b6a2
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@

- [#11412](https://github.com/apollographql/apollo-client/pull/11412) [`58db5c3`](https://github.com/apollographql/apollo-client/commit/58db5c3295b88162f91019f0898f6baa4b9cced6) Thanks [@jerelmiller](https://github.com/jerelmiller)! - Add the ability to start preloading a query outside React to begin fetching as early as possible. Call `createQueryPreloader` to create a `preloadQuery` function which can be called to start fetching a query. This returns a `queryRef` which is passed to `useReadQuery` and suspended until the query is done fetching.

```tsx
const preloadQuery = createQueryPreloader(client);
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });

function App() {
return {
<Suspense fallback={<div>Loading</div>}>
<MyQuery />
</Suspense>
}
}

function MyQuery() {
const { data } = useReadQuery(queryRef);

// do something with data
}
```

#### Testing utility improvements

- [#11178](https://github.com/apollographql/apollo-client/pull/11178) [`4d64a6f`](https://github.com/apollographql/apollo-client/commit/4d64a6fa2ad5abe6f7f172c164f5e1fc2cb89829) Thanks [@sebakerckhof](https://github.com/sebakerckhof)! - Support re-using of mocks in the MockedProvider
Expand Down Expand Up @@ -193,25 +212,6 @@

The `IGNORE` sentinel can be destructured from the second parameter in the callback function signature passed to `optimisticResponse`.

```tsx
const preloadQuery = createQueryPreloader(client);
const queryRef = preloadQuery(QUERY, { variables, ...otherOptions });

function App() {
return {
<Suspense fallback={<div>Loading</div>}>
<MyQuery />
</Suspense>
}
}

function MyQuery() {
const { data } = useReadQuery(queryRef);

// do something with data
}
```

#### Network adapters for multipart subscriptions usage with Relay and urql

- [#11301](https://github.com/apollographql/apollo-client/pull/11301) [`46ab032`](https://github.com/apollographql/apollo-client/commit/46ab032af83a01f184bfcce5edba4b55dbb2962a) Thanks [@alessbell](https://github.com/alessbell)! - Add multipart subscription network adapters for Relay and urql
Expand Down

0 comments on commit aa7b6a2

Please sign in to comment.