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

injectQuery.md

350 lines23.2 KB

1---
2id: injectQuery
3title: injectQuery
4---
5​
6## Overview
7​
8```ts
9function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): DefinedCreateQueryResult<TData, TError>;
10function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
11function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
12```
13​
14- [`() => DefinedInitialDataOptions` β†’ `DefinedCreateQueryResult`](#call-signature-1): This overload is selected when `initialData` is set on the options returned by `injectQueryFn`, so the resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).
15- [`() => UndefinedInitialDataOptions` β†’ `CreateQueryResult`](#call-signature-2): Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
16- [`() => CreateQueryOptions` β†’ `CreateQueryResult`](#call-signature-3): This overload accepts the general [CreateQueryOptions](../interfaces/CreateQueryOptions.md) shape rather than the `initialData`-aware overloads above, so whether `data` is defined can't be inferred from the call site β€” useful when wrapping `injectQuery` in your own helper function that forwards caller-provided options.
17​
18See also: [Parameters](#parameters-summary) Β· [Returns](#returns-summary)
19​
20<a id="call-signature-1"></a>
21​
22## Call Signature
23​
24```ts
25function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): DefinedCreateQueryResult<TData, TError>;
26```
27​
28Defined in: [packages/angular-query-experimental/src/inject-query.ts:70](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L70)
29​
30This overload is selected when `initialData` is set on the options returned by `injectQueryFn`, so the
31resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`).
32​
33### Type Parameters
34​
35#### TQueryFnData
36​
37`TQueryFnData` = `unknown`
38​
39#### TError
40​
41`TError` = `Error`
42​
43#### TData
44​
45`TData` = `TQueryFnData`
46​
47#### TQueryKey
48​
49`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[]
50​
51### Parameters
52​
53#### injectQueryFn
54​
55() => [`DefinedInitialDataOptions`](../type-aliases/DefinedInitialDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>
56​
57A function returning the [DefinedInitialDataOptions](../type-aliases/DefinedInitialDataOptions.md) to use β€” everything you
58can pass to `injectQuery`, with `initialData` set. Similar to `computed` from Angular, this function runs
59in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.
60​
61#### options?
62​
63[`InjectQueryOptions`](../interfaces/InjectQueryOptions.md)
64​
65Additional configuration
66​
67### Returns
68​
69[`DefinedCreateQueryResult`](../type-aliases/DefinedCreateQueryResult.md)\<`TData`, `TError`\>
70​
71The query result, typed so that `data` is never `undefined` (unless a `select` changes `TData` to
72include `undefined`).
73​
74### See
75​
76 - https://tanstack.com/query/latest/docs/framework/angular/guides/queries
77 - [queryOptions](queryOptions.md) to share these options between `injectQuery` and imperative APIs like
78`queryClient.fetchQuery`.
79​
80### Example
81​
82```angular-ts
83@Component({
84 selector: 'posts',
85 template: `
86 <!-- `postsQuery.data()` is `Post[]`, never `undefined`, thanks to `initialData` β€” even if a
87 refetch fails, so the list stays visible alongside the error. -->
88 @if (postsQuery.isError()) {
89 <span>Error: {{ postsQuery.error()?.message }}</span>
90 }
91 <ul>
92 @for (post of postsQuery.data(); track post.id) {
93 <li>{{ post.title }}</li>
94 }
95 </ul>
96 `,
97})
98export class Posts {
99 readonly postsQuery = injectQuery(() => ({
100 queryKey: ['posts'],
101 queryFn: fetchPosts,
102 initialData: [],
103 }))
105```
106​
107<a id="call-signature-2"></a>
108​
109## Call Signature
110​
111```ts
112function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
113```
114​
115Defined in: [packages/angular-query-experimental/src/inject-query.ts:156](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L156)
116​
117Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.
118​
119### Type Parameters
120​
121#### TQueryFnData
122​
123`TQueryFnData` = `unknown`
124​
125#### TError
126​
127`TError` = `Error`
128​
129#### TData
130​
131`TData` = `TQueryFnData`
132​
133#### TQueryKey
134​
135`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[]
136​
137### Parameters
138​
139#### injectQueryFn
140​
141() => [`UndefinedInitialDataOptions`](../type-aliases/UndefinedInitialDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>
142​
143A function returning the [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md) to use β€” everything
144you can pass to `injectQuery`. Similar to `computed` from Angular, this function runs in the reactive
145context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive the query.
146​
147#### options?
148​
149[`InjectQueryOptions`](../interfaces/InjectQueryOptions.md)
150​
151Additional configuration
152​
153### Returns
154​
155[`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\>
156​
157The query result. `status()` is `'pending'` if there is no cached data to display, `'error'` if
158the last fetch attempt failed, or `'success'` if the query has data to display. `isPending`/`isSuccess`/
159`isError` are type-guard methods for convenience.
160​
161### See
162​
163 - https://tanstack.com/query/latest/docs/framework/angular/guides/queries
164 - [queryOptions](queryOptions.md) to share these options between `injectQuery` and imperative APIs like
165`queryClient.fetchQuery`.
166​
167### Examples
168​
169```angular-ts
170@Component({
171 selector: 'posts',
172 template: `
173 @if (postsQuery.isPending()) {
174 Loading...
175 } @else if (postsQuery.isError()) {
176 <span>Error: {{ postsQuery.error()?.message }}</span>
177 } @else {
178 <ul>
179 @for (post of postsQuery.data(); track post.id) {
180 <li>{{ post.title }}</li>
181 }
182 </ul>
183 }
184 `,
185})
186export class Posts {
187 readonly postsQuery = injectQuery(() => ({
188 queryKey: ['posts'],
189 queryFn: fetchPosts,
190 }))
192```
193​
194Similar to `computed` from Angular, the function passed to `injectQuery` runs in the reactive context. In
195the example below, the query is automatically enabled and executed when the filter signal changes to a
196truthy value. When the filter signal changes back to a falsy value, the query is disabled.
197```angular-ts
198@Component({
199 selector: 'posts',
200 template: `
201 <input [ngModel]="filter()" (ngModelChange)="filter.set($event)" />
202 @if (postsQuery.isPending()) {
203 Loading...
204 } @else if (postsQuery.isError()) {
205 <span>Error: {{ postsQuery.error()?.message }}</span>
206 } @else {
207 <ul>
208 @for (post of postsQuery.data(); track post.id) {
209 <li>{{ post.title }}</li>
210 }
211 </ul>
212 }
213 `,
214})
215export class Posts {
216 readonly filter = signal('')
217​
218 readonly postsQuery = injectQuery(() => ({
219 queryKey: ['posts', this.filter()],
220 queryFn: () => fetchPosts(this.filter()),
221 // Signals can be combined with expressions
222 enabled: !!this.filter(),
223 }))
225```
226​
227<a id="call-signature-3"></a>
228​
229## Call Signature
230​
231```ts
232function injectQuery<TQueryFnData, TError, TData, TQueryKey>(injectQueryFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>, options?: InjectQueryOptions): CreateQueryResult<TData, TError>;
233```
234​
235Defined in: [packages/angular-query-experimental/src/inject-query.ts:182](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L182)
236​
237This overload accepts the general [CreateQueryOptions](../interfaces/CreateQueryOptions.md) shape rather than the `initialData`-aware
238overloads above, so whether `data` is defined can't be inferred from the call site β€” useful when wrapping
239`injectQuery` in your own helper function that forwards caller-provided options.
240​
241### Type Parameters
242​
243#### TQueryFnData
244​
245`TQueryFnData` = `unknown`
246​
247#### TError
248​
249`TError` = `Error`
250​
251#### TData
252​
253`TData` = `TQueryFnData`
254​
255#### TQueryKey
256​
257`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[]
258​
259### Parameters
260​
261#### injectQueryFn
262​
263() => [`CreateQueryOptions`](../interfaces/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>
264​
265A function that returns query options. Similar to `computed` from Angular, this
266function runs in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive
267the query.
268​
269#### options?
270​
271[`InjectQueryOptions`](../interfaces/InjectQueryOptions.md)
272​
273Additional configuration
274​
275### Returns
276​
277[`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\>
278​
279The query result.
280​
281### See
282​
283https://tanstack.com/query/latest/docs/framework/angular/guides/queries
284​
285<a id="parameters-summary"></a>
286​
287## Parameters
288​
289### injectQueryFn
290​
291() => [`CreateQueryOptions`](../interfaces/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>
292​
293A function that returns query options. Similar to `computed` from Angular, this
294function runs in the reactive context, so signals read inside it (in `queryKey`, `enabled`, etc.) drive
295the query.
296​
297<a id="injectQueryFn-properties"></a>
298​
299#### `injectQueryFn` properties
300​
301| Property | Type | Default value | Description |
302| ------ | ------ | ------ | ------ |
303| <a id="injectQueryFn-property-enabled"></a> `enabled?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. To refetch the query, use the `refetch` method returned from the `useQuery` instance. Accepts a boolean or function that returns a boolean. |
304| <a id="injectQueryFn-property-gctime"></a> `gcTime?` | `number` | `undefined` | The time in milliseconds that unused/inactive cache data remains in memory. When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. When different garbage collection times are specified, the longest one will be used. Setting it to `Infinity` will disable garbage collection. Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay β€” see `timeoutManager.setTimeoutProvider` for a workaround. |
305| <a id="injectQueryFn-property-initialdata"></a> `initialData?` | `TQueryFnData` \| (() => `TQueryFnData` \| `undefined`) | `undefined` | If set, this value will be used as the initial data for the query cache (as long as the query hasn't been created or cached yet). If set to a function, the function will be called **once** during the shared/root query initialization, and be expected to synchronously return the initial data. Initial data is considered stale by default unless a `staleTime` has been set. `initialData` **is persisted** to the cache. |
306| <a id="injectQueryFn-property-initialdataupdatedat"></a> `initialDataUpdatedAt?` | `number` \| (() => `number` \| `undefined`) | `undefined` | If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. |
307| <a id="injectQueryFn-property-maxpages"></a> `maxPages?` | `number` | `undefined` | Maximum number of pages to store in the data of an infinite query. |
308| <a id="injectQueryFn-property-meta"></a> `meta?` | `Record`\<`string`, `unknown`\> | `undefined` | Additional payload to be stored on each query. Use this property to pass information that can be used in other places. |
309| <a id="injectQueryFn-property-networkmode"></a> `networkMode?` | `"online"` \| `"always"` \| `"offlineFirst"` | `'online'` | Controls whether a query is allowed to run based on the current network connectivity. **See** [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. |
310| <a id="injectQueryFn-property-notifyonchangeprops"></a> `notifyOnChangeProps?` | \| ( \| `"error"` \| `"data"` \| `"isError"` \| `"isPending"` \| `"isLoading"` \| `"isLoadingError"` \| `"isRefetchError"` \| `"isSuccess"` \| `"isPlaceholderData"` \| `"status"` \| `"dataUpdatedAt"` \| `"errorUpdatedAt"` \| `"failureCount"` \| `"failureReason"` \| `"errorUpdateCount"` \| `"isFetched"` \| `"isFetchedAfterMount"` \| `"isFetching"` \| `"isInitialLoading"` \| `"isPaused"` \| `"isRefetching"` \| `"isStale"` \| `"isEnabled"` \| `"refetch"` \| `"fetchStatus"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `"all"` \| (() => \| `"all"` \| ( \| `"error"` \| `"data"` \| `"isError"` \| `"isPending"` \| `"isLoading"` \| `"isLoadingError"` \| `"isRefetchError"` \| `"isSuccess"` \| `"isPlaceholderData"` \| `"status"` \| `"dataUpdatedAt"` \| `"errorUpdatedAt"` \| `"failureCount"` \| `"failureReason"` \| `"errorUpdateCount"` \| `"isFetched"` \| `"isFetchedAfterMount"` \| `"isFetching"` \| `"isInitialLoading"` \| `"isPaused"` \| `"isRefetching"` \| `"isStale"` \| `"isEnabled"` \| `"refetch"` \| `"fetchStatus"` \| `"fetchNextPage"` \| `"fetchPreviousPage"` \| `"hasNextPage"` \| `"hasPreviousPage"` \| `"isFetchNextPageError"` \| `"isFetchingNextPage"` \| `"isFetchPreviousPageError"` \| `"isFetchingPreviousPage"`)[] \| `undefined`) | `undefined` | If set, the component will only re-render if any of the listed properties change. When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. When set to `'all'`, the component will re-render whenever a query is updated. When set to a function, the function will be executed to compute the list of properties. Defaults to `undefined`, in which case property access is tracked automatically, and the component only re-renders when one of the tracked properties changes. |
311| <a id="injectQueryFn-property-persister"></a> `persister?` | (`queryFn`: (`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>, `context`: `object`, `query`: [`Query`](../classes/Query.md)) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\> | `undefined` | This option can be used to persist the result of a query to an external storage, bypassing the need to actually call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. |
312| <a id="injectQueryFn-property-placeholderdata"></a> `placeholderData?` | \| `NonFunctionGuard`\<`TQueryFnData`\> \| ((`previousData`: `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`, `previousQuery`: \| [`Query`](../classes/Query.md)\<`NonFunctionGuard`\<`TQueryFnData`\>, `TError`, `NonFunctionGuard`\<`TQueryFnData`\>, `TQueryKey`\> \| `undefined`) => `NonFunctionGuard`\<`TQueryFnData`\> \| `undefined`) | `undefined` | If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. |
313| <a id="injectQueryFn-property-queryfn"></a> `queryFn?` | \| *typeof* [`skipToken`](../variables/skipToken.md) \| ((`context`: `object`) => `TQueryFnData` \| `Promise`\<`TQueryFnData`\>) | `undefined` | The function that the query will use to request data. Required, unless a default query function has been set via `queryClient.setQueryDefaults` or `queryClient.setDefaultOptions`. Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. |
314| <a id="injectQueryFn-property-queryhash"></a> `queryHash?` | `string` | `undefined` | The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used as the actual cache key internally. |
315| <a id="injectQueryFn-property-querykey"></a> `queryKey` | `TQueryKey` & `object` | `undefined` | The query key to use for this query. The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) for more information. The query will automatically update when this key changes (as long as `enabled` is not set to `false`). |
316| <a id="injectQueryFn-property-querykeyhashfn"></a> `queryKeyHashFn?` | (`queryKey`: `TQueryKey`) => `string` | `undefined` | If specified, this function is used to hash the `queryKey` to a string. |
317| <a id="injectQueryFn-property-refetchinterval"></a> `refetchInterval?` | \| `number` \| `false` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `false` \| `undefined`) | `false` | If set to a number, the query will continuously refetch at this frequency in milliseconds. If set to a function, the function will be executed with the latest data and query to compute a frequency |
318| <a id="injectQueryFn-property-refetchintervalinbackground"></a> `refetchIntervalInBackground?` | `boolean` | `false` | If set to `true`, the query will continue to refetch while their tab/window is in the background. |
319| <a id="injectQueryFn-property-refetchonmount"></a> `refetchOnMount?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on mount if the data is stale. If set to `false`, will disable additional instances of a query to trigger background refetch. If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value |
320| <a id="injectQueryFn-property-refetchonreconnect"></a> `refetchOnReconnect?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `undefined` | If set to `true`, the query will refetch on reconnect if the data is stale. If set to `false`, the query will not refetch on reconnect. If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. Defaults to `true` unless `networkMode` is `'always'`. |
321| <a id="injectQueryFn-property-refetchonwindowfocus"></a> `refetchOnWindowFocus?` | \| `boolean` \| `"always"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean` \| `"always"`) | `true` | If set to `true`, the query will refetch on window focus if the data is stale. If set to `false`, the query will not refetch on window focus. If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). If set to a function, the function will be executed with the latest data and query to compute the value. |
322| <a id="injectQueryFn-property-retry"></a> `retry?` | \| `number` \| `false` \| `true` \| ((`failureCount`: `number`, `error`: `TError`) => `boolean`) | `undefined` | If `false`, failed queries will not retry by default. If `true`, failed queries will retry infinitely. If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. Defaults to `3` on the client and `0` on the server. |
323| <a id="injectQueryFn-property-retrydelay"></a> `retryDelay?` | `number` \| ((`failureCount`: `number`, `error`: `TError`) => `number`) | `undefined` | This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the next attempt in milliseconds. A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential backoff. A function like `attempt => attempt * 1000` applies linear backoff. Defaults to a function that applies exponential backoff, capped at 30 seconds. |
324| <a id="injectQueryFn-property-retryonmount"></a> `retryOnMount?` | \| `false` \| `true` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `true` | If set to `false`, the query will not be retried on mount if it contains an error. If set to a function, the function will be executed with the query to compute the value. |
325| <a id="injectQueryFn-property-select"></a> `select?` | (`data`: `TQueryFnData`) => `TData` | `undefined` | This option can be used to transform or select a part of the data returned by the query function. It affects the returned `data` value, but does not affect what gets stored in the query cache. The `select` function will only run if `data` changed, or if the reference to the `select` function itself changes. To optimize, memoize the function so its reference stays stable across calls. |
326| <a id="injectQueryFn-property-staletime"></a> `staleTime?` | \| `number` \| `"static"` \| ((`query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `number` \| `"static"`) | `0` | The time in milliseconds after data is considered stale. If set to `Infinity`, the data will never be considered stale. If set to `'static'`, the data will never be considered stale. If set to a function, the function will be executed with the query to compute a `staleTime`. |
327| <a id="injectQueryFn-property-structuralsharing"></a> `structuralSharing?` | `boolean` \| ((`oldData`: `unknown`, `newData`: `unknown`) => `unknown`) | `true` | Set this to `false` to disable structural sharing between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. |
328| <a id="injectQueryFn-property-throwonerror"></a> `throwOnError?` | \| `false` \| `true` \| ((`error`: `TError`, `query`: [`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryFnData`, `TQueryKey`\>) => `boolean`) | `false` | Whether errors should be thrown instead of setting the `error` property. If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. If set to `false` and `suspense` is `false`, errors are returned as state. If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). |
329​
330### options?
331​
332[`InjectQueryOptions`](../interfaces/InjectQueryOptions.md)
333​
334Additional configuration
335​
336<a id="options-properties"></a>
337​
338#### `options` properties
339​
340| Property | Type | Description |
341| ------ | ------ | ------ |
342| <a id="options-property-injector"></a> `injector?` | `Injector` | The `Injector` in which to create the query. If this is not provided, the current injection context will be used instead (via `inject`). |
343​
344<a id="returns-summary"></a>
345​
346## Returns
347​
348[`CreateQueryResult`](../type-aliases/CreateQueryResult.md)\<`TData`, `TError`\>
349​
350The query result.