Skip to content

Commit

Permalink
Update changelog to remove breaking change for skip token section
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Aug 3, 2023
1 parent 0e3ed26 commit 06eb2b8
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@
We are considering the removal of the `skip` option from `useSuspenseQuery` and `useBackgroundQuery` in the next major. We are releasing with it now to make migration from `useQuery` easier and make `skipToken` more discoverable.
**`useSuspenseQuery`**
```ts
import { skipToken } from "@apollo/client";
import { skipToken, useSuspenseQuery } from "@apollo/client";

const id: number | undefined;

Expand All @@ -157,37 +159,13 @@
);
```
##### Breaking change
Previously `useBackgroundQuery` would always return a `queryRef` whenever query execution was skipped. This behavior been updated to return a `queryRef` only when query execution is enabled. If initializing the hook with it skipped, `queryRef` is now returned as `undefined`.
To migrate, conditionally render the component that accepts the `queryRef` as props.
**Before**
**`useBackgroundQuery`**
```ts
function Parent() {
const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined);
// ^? QueryReference<TData | undefined>

return <Child queryRef={queryRef} />;
}
import { skipToken, useBackgroundQuery } from '@apollo/client';

function Child({
queryRef,
}: {
queryRef: QueryReference<TData | undefined>;
}) {
const { data } = useReadQuery(queryRef);
}
```
**After**
```ts
function Parent() {
const [queryRef] = useBackgroundQuery(query, skip ? skipToken : undefined);
// ^? QueryReference<TData> | undefined

return queryRef ? <Child queryRef={queryRef} /> : null;
}
Expand Down

0 comments on commit 06eb2b8

Please sign in to comment.