@@ -18,7 +18,7 @@ describe('Tanstack Query Plugin Tests', () => {
18
18
19
19
const sharedModel = `
20
20
model User {
21
- id String @id
21
+ id String @id @default(cuid())
22
22
createdAt DateTime @default(now())
23
23
updatedAt DateTime @updatedAt
24
24
email String @unique
@@ -32,7 +32,7 @@ enum role {
32
32
}
33
33
34
34
model post_Item {
35
- id String @id
35
+ id String @id @default(cuid())
36
36
createdAt DateTime @default(now())
37
37
updatedAt DateTime @updatedAt
38
38
title String
@@ -51,13 +51,28 @@ model Foo {
51
51
const reactAppSource = {
52
52
name : 'main.ts' ,
53
53
content : `
54
- import { useInfiniteFindManypost_Item } from './hooks';
54
+ import { useFindFirstpost_Item, useInfiniteFindManypost_Item, useCreatepost_Item } from './hooks';
55
55
56
- const { data, fetchNextPage, hasNextPage } = useInfiniteFindManypost_Item();
57
- useInfiniteFindManypost_Item({ where: { published: true } });
58
- useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
59
- console.log(data?.pages[0][0].published);
60
- console.log(data?.pageParams[0]);
56
+ function query() {
57
+ const { data } = useFindFirstpost_Item({include: { author: true }});
58
+ console.log(data?.viewCount);
59
+ console.log(data?.author?.email);
60
+ }
61
+
62
+ function infiniteQuery() {
63
+ const { data, fetchNextPage, hasNextPage } = useInfiniteFindManypost_Item();
64
+ useInfiniteFindManypost_Item({ where: { published: true } });
65
+ useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
66
+ console.log(data?.pages[0][0].published);
67
+ console.log(data?.pageParams[0]);
68
+ }
69
+
70
+ async function mutation() {
71
+ const { mutateAsync } = useCreatepost_Item();
72
+ const data = await mutateAsync({ data: { title: 'hello' }, include: { author: true } });
73
+ console.log(data?.viewCount);
74
+ console.log(data?.author?.email);
75
+ }
61
76
` ,
62
77
} ;
63
78
@@ -108,11 +123,13 @@ ${sharedModel}
108
123
content : `
109
124
import { useSuspenseInfiniteFindManypost_Item } from './hooks';
110
125
111
- const { data, fetchNextPage, hasNextPage } = useSuspenseInfiniteFindManypost_Item();
112
- useSuspenseInfiniteFindManypost_Item({ where: { published: true } });
113
- useSuspenseInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
114
- console.log(data?.pages[0][0].published);
115
- console.log(data?.pageParams[0]);
126
+ function suspenseInfiniteQuery() {
127
+ const { data, fetchNextPage, hasNextPage } = useSuspenseInfiniteFindManypost_Item();
128
+ useSuspenseInfiniteFindManypost_Item({ where: { published: true } });
129
+ useSuspenseInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
130
+ console.log(data?.pages[0][0].published);
131
+ console.log(data?.pageParams[0]);
132
+ }
116
133
` ,
117
134
} ,
118
135
] ,
@@ -123,13 +140,28 @@ ${sharedModel}
123
140
const vueAppSource = {
124
141
name : 'main.ts' ,
125
142
content : `
126
- import { useInfiniteFindManypost_Item } from './hooks';
143
+ import { useFindFirstpost_Item, useInfiniteFindManypost_Item, useCreatepost_Item } from './hooks';
144
+
145
+ function query() {
146
+ const { data } = useFindFirstpost_Item({include: { author: true }});
147
+ console.log(data.value?.viewCount);
148
+ console.log(data.value?.author?.email);
149
+ }
127
150
128
- const { data, fetchNextPage, hasNextPage } = useInfiniteFindManypost_Item();
129
- useInfiniteFindManypost_Item({ where: { published: true } });
130
- useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
131
- console.log(data.value?.pages[0][0].published);
132
- console.log(data.value?.pageParams[0]);
151
+ function infiniteQuery() {
152
+ const { data, fetchNextPage, hasNextPage } = useInfiniteFindManypost_Item();
153
+ useInfiniteFindManypost_Item({ where: { published: true } });
154
+ useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
155
+ console.log(data.value?.pages[0][0].published);
156
+ console.log(data.value?.pageParams[0]);
157
+ }
158
+
159
+ async function mutation() {
160
+ const { mutateAsync } = useCreatepost_Item();
161
+ const data = await mutateAsync({ data: { title: 'hello' }, include: { author: true } });
162
+ console.log(data?.viewCount);
163
+ console.log(data?.author?.email);
164
+ }
133
165
` ,
134
166
} ;
135
167
@@ -182,13 +214,28 @@ ${sharedModel}
182
214
name : 'main.ts' ,
183
215
content : `
184
216
import { get } from 'svelte/store';
185
- import { useInfiniteFindManypost_Item } from './hooks';
217
+ import { useFindFirstpost_Item, useInfiniteFindManypost_Item, useCreatepost_Item } from './hooks';
218
+
219
+ function query() {
220
+ const { data } = get(useFindFirstpost_Item({include: { author: true }}));
221
+ console.log(data?.viewCount);
222
+ console.log(data?.author?.email);
223
+ }
224
+
225
+ function infiniteQuery() {
226
+ const { data, fetchNextPage, hasNextPage } = get(useInfiniteFindManypost_Item());
227
+ useInfiniteFindManypost_Item({ where: { published: true } });
228
+ useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
229
+ console.log(data?.pages[0][0].published);
230
+ console.log(data?.pageParams[0]);
231
+ }
186
232
187
- const { data, fetchNextPage, hasNextPage } = get(useInfiniteFindManypost_Item());
188
- useInfiniteFindManypost_Item({ where: { published: true } });
189
- useInfiniteFindManypost_Item(undefined, { getNextPageParam: () => null });
190
- console.log(data?.pages[0][0].published);
191
- console.log(data?.pageParams[0]);
233
+ async function mutation() {
234
+ const { mutateAsync } = get(useCreatepost_Item());
235
+ const data = await mutateAsync({ data: { title: 'hello' }, include: { author: true } });
236
+ console.log(data?.viewCount);
237
+ console.log(data?.author?.email);
238
+ }
192
239
` ,
193
240
} ;
194
241
0 commit comments