diff --git a/server/schema/schema.js b/server/schema/schema.js index 1c0e87d..15fa367 100644 --- a/server/schema/schema.js +++ b/server/schema/schema.js @@ -20,7 +20,7 @@ const BookType = new GraphQLObjectType({ author: { type: AuthorType, resolve (parent, args) { - // return _.find(authors, { id: parent.authorId }); + return Author.findById(parent.authorId); } } }) @@ -35,7 +35,7 @@ const AuthorType = new GraphQLObjectType({ books: { type: new GraphQLList(BookType), resolve (parent, args) { - // return _.filter(books, { authorId: parent.id }); + return Book.find({ authorId: parent.id }); } } }) @@ -48,26 +48,26 @@ const RootQuery = new GraphQLObjectType({ type: BookType, args: { id: { type: GraphQLID } }, resolve (parent, args) { - // return _.find(books, { id: args.id }); + return Book.findById(args.id); } }, author: { type: AuthorType, args: { id: { type: GraphQLID } }, resolve (parent, args) { - // return _.find(authors, { id: args.id }); + return Author.findById(args.id); } }, books: { type: new GraphQLList(BookType), resolve (parent, args) { - // return books; + return Book.find({}); } }, authors: { type: new GraphQLList(AuthorType), resolve (parent, args) { - // return authors; + return Author.find({}); } } }