Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/react/guides/query-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The `QueryFunctionContext` is the object passed to each query function. It consi
- [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) instance provided by TanStack Query
- Can be used for [Query Cancellation](../guides/query-cancellation)
- `meta: Record<string, unknown> | undefined`
- an optional field you can fill with additional information about your query#
- an optional field you can fill with additional information about your query

Additionally, [Infinite Queries](../guides/infinite-queries) get the following options passed:

Expand Down
22 changes: 22 additions & 0 deletions docs/react/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,28 @@ const { error } = useQuery({ queryKey: ['groups'], queryFn: fetchGroups })
```

[//]: # 'RegisterErrorType'

[//]: # 'TypingMeta'

## Typing meta

[//]: # 'RegisterMetaType'

### Registering global Meta

Similarly to registering a [global error type](#registering-a-global-error) you can also register a global `Meta` type. This ensures the optional `meta` field on [queries](./reference/useQuery.md) and [mutations](./reference/useMutation.md) stays consistent and is type-safe.

```ts
declare module '@tanstack/react-query' {
interface Register {
queryMeta: MyMeta,
mutationMeta: MyMeta
}
}
```
[//]: # 'RegisterMetaType'
[//]: # 'TypingMeta'

[//]: # 'TypingQueryOptions'

## Typing Query Options
Expand Down