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
Copy file name to clipboardExpand all lines: docs/reference/plugins/tanstack-query.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,8 @@ import FineGrainedOptimistic from './_fine-grained-optimistic.md';
16
16
If you're looking for generating hooks for [SWR](https://swr.vercel.app/), please checkout the [`@zenstackhq/swr`](./swr) plugin.
17
17
:::
18
18
19
-
The `@zenstackhq/tanstack-query` plugin generates [Tanstack Query](https://tanstack.com/query/latest) hooks that call into the CRUD services provided by the [server adapters](../../category/server-adapters). The plugin currently supports React and Svelte. Vue support is coming soon.
19
+
The `@zenstackhq/tanstack-query` plugin generates [TanStack Query](https://tanstack.com/query/latest) hooks that call into the CRUD services provided by the [server adapters](../../category/server-adapters). The plugin currently supports React, Vue, Svelte, and Angular (v5 only).
20
+
20
21
21
22
The hooks syntactically mirror the APIs of a standard Prisma client, including the function names and shapes of parameters (hooks directly use types generated by Prisma).
| output | String | Output directory (relative to the path of ZModel) | Yes ||
36
37
| target | String | Target framework to generate for. Choose from "react", "vue", "svelte", "angular". | Yes ||
37
-
| version | String | Version of TanStack Query to generate for. Choose from "v4" and "v5". Angular supports only v5| No | v5 |
38
+
| version | String | Version of TanStack Query to generate for. Choose from "v4" and "v5". Angular supports only "v5"| No | v5 |
38
39
| portable | Boolean | Include TypeScript types needed to compile the generated code in the output directory. Useful when you output into another project that doesn't reference Prisma and ZenStack. You'll still need to install the "@zenstackhq/tanstack-query" package in that project. | No | false |
39
40
40
41
### Hooks Signature
@@ -609,8 +610,8 @@ export class PostsComponent {
609
610
return {
610
611
where: { title: { contains: search } },
611
612
include: { author:true },
612
-
orderBy: { createdAt:'desc' },
613
-
} as const; //as const is important for correct type inference!
613
+
orderBy: { createdAt:'desc' } as const,
614
+
}
614
615
});
615
616
616
617
//For Reactivity in angular we have to pass the signal as callback
@@ -622,7 +623,6 @@ export class PostsComponent {
622
623
this.create.mutate({
623
624
data: {
624
625
title:'My awesome post',
625
-
content:'This is the content of my awesome post.',
626
626
authorId:this.id(),
627
627
},
628
628
});
@@ -841,7 +841,7 @@ Here's a quick example of using infinite query to load a list of posts with infi
841
841
842
842
<TabItem value="angular" label="Angular">
843
843
844
-
Here's a quick example of using infinite query to load a list of posts with infinite pagination. See [Tanstack Query documentation](https://tanstack.com/query/v4/docs/svelte/examples/svelte/load-more-infinite-scroll) for more details.
844
+
Here's a quick example of using infinite query to load a list of posts with infinite pagination. See [Tanstack Query documentation](https://tanstack.com/query/v5/docs/framework/angular/examples/infinite-query-with-max-pages) for more details.
0 commit comments