File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ var hobbyData = [
1919] ;
2020
2121var postData = [
22- { id : '1' , comment : 'Building a Mind' , } ,
23- { id : '2' , comment : 'GraphQL is Amazing' , } ,
24- { id : '3' , comment : 'How to Change the World' , } ,
22+ { id : '1' , comment : 'Building a Mind' , userId : '1' } ,
23+ { id : '2' , comment : 'GraphQL is Amazing' , userId : '1' } ,
24+ { id : '3' , comment : 'How to Change the World' , userId : '19' } ,
25+ { id : '4' , comment : 'How to Change the World' , userId : '211' } ,
26+ { id : '5' , comment : 'How to Change the World' , userId : '1' } ,
2527] ;
2628
2729// create types
@@ -52,6 +54,12 @@ const PostType = new GraphQLObjectType({
5254 fields : ( ) => ( {
5355 id : { type : GraphQLID } ,
5456 comment : { type : GraphQLString } ,
57+ user : {
58+ type : UserType ,
59+ resolve ( parent , args ) {
60+ return _ . find ( userData , { id : parent . userId } ) ;
61+ }
62+ }
5563 } )
5664} ) ;
5765
You can’t perform that action at this time.
0 commit comments