Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

provideQueryClient.md

44 lines1.3 KB

1---
2id: provideQueryClient
3title: provideQueryClient
4---
5​
6<!-- DO NOT EDIT: this page is autogenerated from the type comments -->
7​
8```ts
9function provideQueryClient(queryClient:
10 | QueryClient
11 | InjectionToken<QueryClient>): Provider;
12```
13​
14Defined in: [packages/angular-query-experimental/src/providers.ts:21](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L21)
15​
16Usually [provideTanStackQuery](provideTanStackQuery.md) is used once to set up TanStack Query and the
17[`QueryClient`](https://tanstack.com/query/latest/docs/reference/QueryClient) for the entire application β€”
18it calls `provideQueryClient` internally. Use `provideQueryClient` directly to provide a different
19`QueryClient` instance for part of the application, or for unit testing.
20​
21## Parameters
22​
23### queryClient
24​
25 \| [`QueryClient`](../classes/QueryClient.md)
26 \| `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\>
27​
28A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`.
29​
30## Returns
31​
32`Provider`
33​
34A provider object that can be used to provide the `QueryClient` instance.
35​
36## Example
37​
38Providing a test-only `QueryClient` in a component test, without wiring up `provideTanStackQuery`'s other
39defaults:
40```ts
41TestBed.configureTestingModule({
42 providers: [provideQueryClient(new QueryClient())],
43})
44```