Skip to content

Commit d4f42d2

Browse files
committed
feat: updated queries to mongodb
1 parent 85a4f69 commit d4f42d2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"install": "cd server && npm i",
9-
"start": "node server/app.js"
9+
"start": "cd server && node app.js"
1010
},
1111
"repository": {
1212
"type": "git",

server/schema/schema.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const HobbyType = new GraphQLObjectType({
6666
user: {
6767
type: UserType,
6868
resolve(parent, args){
69-
return _.find(userData, {id: parent.userId});
69+
return User.findById(parent.userId);
7070
}
7171
},
7272
})
@@ -81,7 +81,7 @@ const PostType = new GraphQLObjectType({
8181
user: {
8282
type: UserType,
8383
resolve(parent, args){
84-
return _.find(userData, {id: parent.userId});
84+
return User.findById(parent.userId);
8585
}
8686
},
8787
})
@@ -96,7 +96,7 @@ const RootQuery = new GraphQLObjectType({
9696
users:{
9797
type: new GraphQLList(UserType),
9898
resolve(parent, args){
99-
return userData;
99+
return User.find({});
100100
}
101101
},
102102

@@ -111,30 +111,30 @@ const RootQuery = new GraphQLObjectType({
111111
hobbies:{
112112
type: new GraphQLList(HobbyType),
113113
resolve(parent, args){
114-
return hobbiesData;
114+
return Hobby.find({});
115115
}
116116
},
117117

118118
hobby:{
119119
type: HobbyType,
120120
args: {id: {type: GraphQLID}},
121121
resolve(parent, args){
122-
return _.find(hobbiesData, {id: args.id});
122+
return Hobby.find({ id: args.userId });
123123
}
124124
},
125125

126126
posts:{
127127
type: new GraphQLList(PostType),
128128
resolve(parent, args){
129-
return postsData;
129+
return Post.find({});
130130
}
131131
},
132132

133133
post:{
134134
type: PostType,
135135
args: {id: {type: GraphQLID}},
136136
resolve(parent, args){
137-
return _.find(postsData, {id: args.id});
137+
return Post.findById(args.id);
138138
}
139139
},
140140

0 commit comments

Comments
 (0)