diff --git a/server/schema/schema.js b/server/schema/schema.js index d125a0c..b1b0733 100644 --- a/server/schema/schema.js +++ b/server/schema/schema.js @@ -11,9 +11,9 @@ const { // temp data const books = [ - { name: 'Name of the Wind', genre: 'Fantasy', id: '1' }, - { name: 'The Final Empire', genre: 'Fantasy', id: '2' }, - { name: 'The Long Earth', genre: 'Sci-Fi', id: '3' } + { name: 'Name of the Wind', genre: 'Fantasy', id: '1', authorId: '1' }, + { name: 'The Final Empire', genre: 'Fantasy', id: '2', authorId: '2' }, + { name: 'The Long Earth', genre: 'Sci-Fi', id: '3', authorId: '3' } ]; const authors = [ { name: 'Patrick Rothfuss', age: 44, id: '1' }, @@ -26,7 +26,13 @@ const BookType = new GraphQLObjectType({ fields: () => ({ id: { type: GraphQLID }, name: { type: GraphQLString }, - genre: { type: GraphQLString } + genre: { type: GraphQLString }, + author: { + type: AuthorType, + resolve (parent, args) { + return _.find(authors, { id: parent.authorId }); + } + } }) });