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
The `data` field returned by the hooks call contains the Prisma query result.
55
+
The hook function returns a standard TanStack Query [`useQuery`](https://tanstack.com/query/latest/docs/framework/react/reference/useQuery) result, plus an added `queryKey` field.
56
+
57
+
- The `data` field contains the Prisma query result.
58
+
- The `queryKey` field is the query key used to cache the query result. It can be used to manipulate the cache directly or [cancel the query](#query-cancellation).
56
59
57
60
-**Mutation Hooks**
58
61
@@ -64,7 +67,7 @@ The generated hooks have the following signature convention.
64
67
-`[Model]`: the name of the model. E.g., "Post".
65
68
-`options`: TanStack-Query options.
66
69
67
-
The `mutate` and `mutateAsync` functions returned with the hooks call take the corresponding Prisma mutation args as input. E.q., `{ data: { title: 'Post1' } }`.
70
+
The hook function returns a standard TanStack Query [`useMutation`](https://tanstack.com/query/latest/docs/framework/react/reference/useMutation) result. The `mutate` and `mutateAsync` functions returned take the corresponding Prisma mutation args as input. E.q., `{ data: { title: 'Post1' } }`.
68
71
69
72
### Context Provider
70
73
@@ -679,6 +682,27 @@ will be:
679
682
680
683
You can use the generated `getQueryKey` function to compute it.
681
684
685
+
The query hooks also return the query key as part of the result object.
You can use TanStack Query's [`queryClient.cancelQueries`](https://tanstack.com/query/latest/docs/reference/QueryClient#queryclientcancelqueries) API to cancel a query. The easiest way to do this is to use the `queryKey` returned by the query hook.
0 commit comments