Skip to content

Commit 0801fc5

Browse files
committed
implemented-code-rabbit-suggestions
1 parent f1cef38 commit 0801fc5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

docs/reference/plugins/tanstack-query.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import FineGrainedOptimistic from './_fine-grained-optimistic.md';
1616
If you're looking for generating hooks for [SWR](https://swr.vercel.app/), please checkout the [`@zenstackhq/swr`](./swr) plugin.
1717
:::
1818

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+
2021

2122
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).
2223

@@ -34,7 +35,7 @@ npm install --save-dev @zenstackhq/tanstack-query
3435
| -------- | ------- | ------------------------------------------------------- | -------- | ------- |
3536
| output | String | Output directory (relative to the path of ZModel) | Yes | |
3637
| 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 |
3839
| 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 |
3940

4041
### Hooks Signature
@@ -609,8 +610,8 @@ export class PostsComponent {
609610
return {
610611
where: { title: { contains: search } },
611612
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+
}
614615
});
615616
616617
//For Reactivity in angular we have to pass the signal as callback
@@ -622,7 +623,6 @@ export class PostsComponent {
622623
this.create.mutate({
623624
data: {
624625
title: 'My awesome post',
625-
content: 'This is the content of my awesome post.',
626626
authorId: this.id(),
627627
},
628628
});
@@ -841,7 +841,7 @@ Here's a quick example of using infinite query to load a list of posts with infi
841841
842842
<TabItem value="angular" label="Angular">
843843
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.
845845
846846
```ts title='src/app/posts/posts.component.ts'
847847
import { CommonModule } from '@angular/common';
@@ -894,7 +894,7 @@ export class PostsComponent {
894894
}
895895
const fetched = pages.flatMap((item) => item).length;
896896
return {
897-
...this.fetchArgs,
897+
...this.fetchArgs(),
898898
skip: fetched,
899899
};
900900
},

0 commit comments

Comments
 (0)