Skip to content

Commit 5647cf2

Browse files
committed
improve documentation
1 parent b5c88f4 commit 5647cf2

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

website/docs/api/builder.mdx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Therefore, it's important to know the available methods that can be used to conf
1414
### withClient
1515

1616
```ts
17-
withClient(client: QueryClient): this
17+
withClient(client: QueryClient, options): this
1818
```
1919

2020
Sets the query client for this builder.
@@ -91,6 +91,17 @@ Adds a declarative update to the mutation.
9191
This is used to invalidate or update the queries that were marked with [withTags](#withtags).
9292
To learn more about tags, see the [tag based invalidation](/tags) section of the documentation.
9393

94+
### withPagination
95+
96+
```ts
97+
withPagination(paginationOptions): this
98+
```
99+
100+
Adds infinite query support to the query.
101+
Requires `getNextPageParam` to be passed in options.
102+
This is required in order to enable the hooks like `useInfiniteQuery`.
103+
Additional options can also be provided which are passed to the underlying hook.
104+
94105
### withData
95106

96107
```ts

website/docs/api/query.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ There is also `useSuspenseQueries` variant.
3434
useInfiniteQuery(vars, queryOptions): InfiniteQueryResult;
3535
```
3636

37-
Infinite query methods are only available if you have configured the builder with `withPagination`.
37+
Infinite query methods are only available if you have configured the builder with [`withPagination`](./builder#withpagination).
3838

3939
There are also `usePrefetchInfiniteQuery` and `useSuspenseInfiniteQuery` variants.
4040

website/docs/tags.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ But in our opinion query keys are hard to manage, as they are highly variable an
1111
For this reason, we introduce a concept of tags.
1212
Tags are a way to mark queries with a specific label. You can easily manipulate the query cache by using these tags.
1313

14+
This feature is heavily inspired by the same feature in
15+
[RTK Query](https://redux-toolkit.js.org/rtk-query/usage/automated-refetching#definitions)
16+
and works similarly.
17+
1418
## How to use tags
1519

1620
You can start by strongly typing the data type that corresponds to each tag:
@@ -57,6 +61,19 @@ const deleteArticleMutation = builder
5761
.withUpdates(({ vars }) => ({ type: "article", id: vars.params.id }));
5862
```
5963

64+
## Syncing between browser tabs
65+
66+
When invalidating queries with tags, same tags are also invalidated in other browser tabs.
67+
This is enabled by default after calling [`withClient`](./api/builder#withclient).
68+
You can disable this behavior by passing the option to the `withClient` method.
69+
70+
```ts
71+
const builder = new HttpQueryBuilder().withClient(queryClient, {
72+
// highlight-next-line
73+
syncTagsWithOtherTabs: false,
74+
});
75+
```
76+
6077
## Optimistic updates
6178

6279
You can also use the tags for updating the query cache.

0 commit comments

Comments
 (0)