Skip to content

Commit

Permalink
update schema & resolvers to query revised mongo document
Browse files Browse the repository at this point in the history
  • Loading branch information
efir-tractatus committed Oct 21, 2020
1 parent 1a8531b commit 3ac30db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/server/resolvers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports.resolvers = {
},
Question: {
answers: (root) => {
return db.Answer.find({ question_id: root.id });
return db.Answer.find({ question_id: root._id });
},
},
// Mutation:{
Expand Down
21 changes: 9 additions & 12 deletions src/server/typeDefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ const { gql } = require('apollo-server-express');

module.exports.typeDefs = gql`
type Question {
id: Float
product_id: Float
_id: ID!
product_id: Float!
body: String
date: String
name: String
email: String
reported: Boolean
helpful: Float
answers_ref: [String]
answers: [Answer]
}
type Answer {
id: Float
question_id: Float
_id: ID!
question_id: ID!
body: String
date: String
name: String
Expand All @@ -29,15 +28,14 @@ module.exports.typeDefs = gql`
type Query {
getAllQuestions: [Question]
getQuestions(product_id: Float): [Question]
getQuestion(id: Float): [Question]
getQuestion(_id: Float): [Question]
getAllAnswers: [Answer]
getAnswers(question_id: Float): [Answer]
getAnswer(id: Float): [Answer]
getAnswer(_id: Float): [Answer]
}
type Mutation {
createUpdateQuestion(
id: Float!
product_id: Float!
body: String
date: String
Expand All @@ -48,8 +46,7 @@ module.exports.typeDefs = gql`
): Question
createUpdateAnswer(
id: Float!
question_id: Float!
question_id: ID!
body: String
date: String
name: String
Expand All @@ -59,7 +56,7 @@ module.exports.typeDefs = gql`
photos: [String]
): Answer
deleteQuestion(id: Float!): Question
deleteAnswer(id: Float!): Answer
deleteQuestion(_id: ID!): Question
deleteAnswer(_id: ID!): Answer
}
`;

0 comments on commit 3ac30db

Please sign in to comment.