@@ -11,11 +11,11 @@ var userData = [
1111] ;
1212
1313var hobbyData = [
14- { id : '1' , title : 'Programming' , description : 'Using computers to make the world a better place' , } ,
15- { id : '2' , title : 'Rowing' , description : 'Sweat and feel better before eating donoughts' , } ,
16- { id : '3' , title : 'Swimming' , description : 'Get in the ware and learn to become the water' , } ,
17- { id : '4' , title : 'Fencing' , description : 'A hobby for fency people' , } ,
18- { id : '5' , title : 'Programming' , description : 'Wear hiking boots and explore the world' , } ,
14+ { id : '1' , title : 'Programming' , description : 'Using computers to make the world a better place' , userId : '150' , } ,
15+ { id : '2' , title : 'Rowing' , description : 'Sweat and feel better before eating donoughts' , userId : '19' , } ,
16+ { id : '3' , title : 'Swimming' , description : 'Get in the ware and learn to become the water' , userId : '1' , } ,
17+ { id : '4' , title : 'Fencing' , description : 'A hobby for fency people' , userId : '150' , } ,
18+ { id : '5' , title : 'Programming' , description : 'Wear hiking boots and explore the world' , userId : '1' , } ,
1919] ;
2020
2121var postData = [
@@ -44,7 +44,13 @@ const HobbyType = new GraphQLObjectType({
4444 fields : ( ) => ( {
4545 id : { type : GraphQLID } ,
4646 title : { type : GraphQLString } ,
47- description : { type : GraphQLString }
47+ description : { type : GraphQLString } ,
48+ user : {
49+ type : UserType ,
50+ resolve ( parent , args ) {
51+ return _ . find ( userData , { id : parent . userId } ) ;
52+ }
53+ } ,
4854 } )
4955} ) ;
5056
@@ -59,7 +65,7 @@ const PostType = new GraphQLObjectType({
5965 resolve ( parent , args ) {
6066 return _ . find ( userData , { id : parent . userId } ) ;
6167 }
62- }
68+ } ,
6369 } )
6470} ) ;
6571
0 commit comments