From 420a4739eb9770fb77752c3d5cc8515070280e2d Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Wed, 29 Jan 2020 01:10:07 -0500 Subject: [PATCH] feat(server): queries to mongoDB --- server/schema/schema.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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({}); } } }