File tree Expand file tree Collapse file tree
.agents/skills/constructive-graphql/references Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -484,6 +484,68 @@ const authorsWithCounts = authors.map(author => ({
484484}));
485485` ` `
486486
487+ ### Posts with Comment Count and Latest Comment
488+
489+ ` ` ` typescript
490+ const posts = await db .post .findMany ({
491+ select: {
492+ id: true ,
493+ title: true ,
494+ comments: {
495+ select: { id: true , body: true , createdAt: true },
496+ orderBy: { createdAt: ' DESC' },
497+ },
498+ },
499+ }).execute ().unwrap ();
500+
501+ const postsWithStats = posts .map (post => ({
502+ id: post .id ,
503+ title: post .title ,
504+ commentCount: post .comments .length ,
505+ latestComment: post .comments [0 ] ?? null ,
506+ }));
507+ ` ` `
508+
509+ ### User Feed with Mixed Content
510+
511+ ` ` ` typescript
512+ const user = await db .user .findOne ({
513+ id: userId ,
514+ select: {
515+ id: true ,
516+ name: true ,
517+ // Own posts
518+ posts: {
519+ select: { id: true , title: true , createdAt: true },
520+ orderBy: { createdAt: ' DESC' },
521+ first: 10 ,
522+ },
523+ // Comments made
524+ comments: {
525+ select: {
526+ id: true ,
527+ body: true ,
528+ createdAt: true ,
529+ post: { select: { id: true , title: true } },
530+ },
531+ orderBy: { createdAt: ' DESC' },
532+ first: 10 ,
533+ },
534+ // Favorites
535+ favorites: {
536+ select: {
537+ post: {
538+ select: { id: true , title: true , author: { select: { name: true } } },
539+ },
540+ createdAt: true ,
541+ },
542+ orderBy: { createdAt: ' DESC' },
543+ first: 10 ,
544+ },
545+ },
546+ }).execute ().unwrap ();
547+ ` ` `
548+
487549### Full M:N Lifecycle
488550
489551` ` ` typescript
You can’t perform that action at this time.
0 commit comments