You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/pages/guides/initial-query-data.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ title: Initial Query Data
6
6
There are many ways to supply initial data for a query to the cache before you need it:
7
7
8
8
- Declaratively:
9
-
- Provide `initialData` to a query to prepopulate the its cache if empty
9
+
- Provide `initialData` to a query to prepopulate its cache if empty
10
10
- Imperatively:
11
11
-[Prefetch the data using `queryClient.prefetchQuery`](../prefetching)
12
12
-[Manually place the data into the cache using `queryClient.setQueryData`](../prefetching)
@@ -42,7 +42,7 @@ By default, `initialData` is treated as totally fresh, as if it were just fetche
42
42
43
43
```js
44
44
functionTodos() {
45
-
// Show initialTodos immeidately, but won't refetch until another interaction event is encountered after 1000 ms
45
+
// Show initialTodos immediately, but won't refetch until another interaction event is encountered after 1000 ms
46
46
returnuseQuery('todos', () =>fetch('/todos'), {
47
47
initialData: initialTodos,
48
48
staleTime:1000,
@@ -53,7 +53,7 @@ By default, `initialData` is treated as totally fresh, as if it were just fetche
53
53
- So what if your `initialData` isn't totally fresh? That leaves us with the last configuration that is actually the most accurate and uses an option called `initialDataUpdatedAt`. This options allows you to pass a numeric JS timestamp in milliseconds of when the initialData itself was last updated, e.g. what `Date.now()` provides. Take note that if you have a unix timestamp, you'll need to convert it to a JS timestamp by multiplying it by `1000`.
54
54
```js
55
55
functionTodos() {
56
-
// Show initialTodos immeidately, but won't refetch until another interaction event is encountered after 1000 ms
56
+
// Show initialTodos immediately, but won't refetch until another interaction event is encountered after 1000 ms
Copy file name to clipboardExpand all lines: docs/src/pages/guides/mutations.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: Mutations
5
5
6
6
Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. For this purpose, Svelte Query exports a `useMutation` hook.
7
7
8
-
Here's an example of a mutation that adds a new todo the server:
8
+
Here's an example of a mutation that adds a new todo to the server:
9
9
10
10
```markdown
11
11
<script>
@@ -214,7 +214,7 @@ const queryClient = new QueryClient()
The options for `fetchQuery` are exactly the same as those of [`useQuery`](#usequery).
91
+
The options for `fetchQuery` are exactly the same as those of [`useQuery`](./useQuery), except the following: `enabled, refetchInterval, refetchIntervalInBackground, refetchOnWindowFocus, refetchOnReconnect, notifyOnChangeProps, notifyOnChangePropsExclusions, onSuccess, onError, onSettled, useErrorBoundary, select, suspense, keepPreviousData, placeholderData`; which are stictly for useQuery and useInfiniteQuery. You can check the [source code](https://github.com/TanStack/svelte-query/blob/864cd6e31b19cea5483d1809d6e3afc1499b48d6/src/queryCore/core/types.ts#L83) for more clarity.
90
92
91
93
**Returns**
92
94
93
95
-`Promise<TData>`
94
96
97
+
## `queryClient.fetchInfiniteQuery`
98
+
99
+
`fetchInfiniteQuery` is similar to `fetchQuery` but can be used to fetch and cache an infinite query.
The options for `fetchInfiniteQuery` are exactly the same as those of [`fetchQuery`](#queryclientfetchquery).
113
+
114
+
**Returns**
115
+
116
+
-`Promise<InfiniteData<TData>>`
117
+
95
118
## `queryClient.prefetchQuery`
96
119
97
120
`prefetchQuery` is an asynchronous method that can be used to prefetch a query before it is needed or rendered with `useQuery` and friends. The method works the same as `fetchQuery` except that is will not throw or return any data.
The options for `prefetchQuery` are exactly the same as those of [`useQuery`](#usequery).
134
+
The options for `prefetchQuery` are exactly the same as those of [`fetchQuery`](#queryclientfetchquery).
135
+
136
+
**Returns**
137
+
138
+
-`Promise<void>`
139
+
- A promise is returned that will either immediately resolve if no fetch is needed or after the query has been executed. It will not return any data or throw any errors.
140
+
141
+
## `queryClient.prefetchInfiniteQuery`
142
+
143
+
`prefetchInfiniteQuery` is similar to `prefetchQuery` but can be used to prefetch and cache an infinite query.
0 commit comments