@@ -18,7 +18,7 @@ describe('Tanstack Query Plugin Tests', () => {
1818
1919 const sharedModel = `
2020model User {
21- id String @id
21+ id String @id @default(cuid())
2222 createdAt DateTime @default(now())
2323 updatedAt DateTime @updatedAt
2424 email String @unique
@@ -32,7 +32,7 @@ enum role {
3232}
3333
3434model post_Item {
35- id String @id
35+ id String @id @default(cuid())
3636 createdAt DateTime @default(now())
3737 updatedAt DateTime @updatedAt
3838 title String
@@ -51,13 +51,28 @@ model Foo {
5151 const reactAppSource = {
5252 name : 'main.ts' ,
5353 content : `
54- import { useInfiniteFindManypost_Item } from './hooks';
54+ import { useFindFirstpost_Item, useInfiniteFindManypost_Item, useCreatepost_Item } from './hooks';
5555
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+ }
6176 ` ,
6277 } ;
6378
@@ -108,11 +123,13 @@ ${sharedModel}
108123 content : `
109124 import { useSuspenseInfiniteFindManypost_Item } from './hooks';
110125
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+ }
116133 ` ,
117134 } ,
118135 ] ,
@@ -123,13 +140,28 @@ ${sharedModel}
123140 const vueAppSource = {
124141 name : 'main.ts' ,
125142 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+ }
127150
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+ }
133165 ` ,
134166 } ;
135167
@@ -182,13 +214,28 @@ ${sharedModel}
182214 name : 'main.ts' ,
183215 content : `
184216 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+ }
186232
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+ }
192239 ` ,
193240 } ;
194241
0 commit comments