From ffc932c6ca3b27777eefa613d941e642a9ebbab1 Mon Sep 17 00:00:00 2001 From: Basti Buck Date: Wed, 18 Oct 2023 20:36:32 +0200 Subject: [PATCH 1/2] chore: typo --- docs/react/guides/query-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/react/guides/query-functions.md b/docs/react/guides/query-functions.md index 6bbbe15ce2..a9fce20f68 100644 --- a/docs/react/guides/query-functions.md +++ b/docs/react/guides/query-functions.md @@ -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 | 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: From c6a49fa46c3a62e5e1fad95ec704ef7dd185acb8 Mon Sep 17 00:00:00 2001 From: Basti Buck Date: Wed, 18 Oct 2023 20:37:36 +0200 Subject: [PATCH 2/2] docs: add global meta registration docs --- docs/react/typescript.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/react/typescript.md b/docs/react/typescript.md index d26f860177..43da2eafca 100644 --- a/docs/react/typescript.md +++ b/docs/react/typescript.md @@ -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