11import { extendType , nonNull , objectType , stringArg } from "nexus" ;
2- import { NexusGenObjects } from "../../nexus-typegen" ;
2+ import { NexusGenObjects } from "../../nexus-typegen" ;
33
44export const Link = objectType ( {
55 name : "Link" ,
@@ -8,10 +8,8 @@ export const Link = objectType({
88 t . nonNull . string ( "description" ) ;
99 t . nonNull . string ( "url" ) ;
1010 t . field ( "postedBy" , {
11-
1211 type : "User" ,
1312 resolve ( parent , args , context ) {
14-
1513 return context . prisma . link
1614 . findUnique ( { where : { id : parent . id } } )
1715 . postedBy ( ) ;
@@ -26,7 +24,6 @@ export const LinkQuery = extendType({
2624 t . nonNull . list . nonNull . field ( "feed" , {
2725 type : "Link" ,
2826 resolve ( parent , args , context ) {
29-
3027 return context . prisma . link . findMany ( ) ;
3128 } ,
3229 } ) ;
@@ -42,24 +39,24 @@ export const LinkMutation = extendType({
4239 description : nonNull ( stringArg ( ) ) ,
4340 url : nonNull ( stringArg ( ) ) ,
4441 } ,
45- resolve ( parent , args , context ) {
42+ resolve ( parent , args , context ) {
4643 const { description, url } = args ;
4744 const { userId } = context ;
4845
49- if ( ! userId ) {
46+ if ( ! userId ) {
5047 throw new Error ( "Cannot post without logging in." ) ;
5148 }
5249
5350 const newLink = context . prisma . link . create ( {
5451 data : {
5552 description,
5653 url,
57- postedBy : { connect : { id : userId } } ,
54+ postedBy : { connect : { id : userId } } ,
5855 } ,
5956 } ) ;
6057
6158 return newLink ;
6259 } ,
6360 } ) ;
6461 } ,
65- } ) ;
62+ } ) ;
0 commit comments