마음연구소 백엔드 과제인 설문지 서비스입니다.
https://dbdiagram.io/d/655330177d8bbd646523b42e
설문지
type Survey {
id: ID!
title: String!
isCompleted: Boolean
question: [Question]
}
type SurveyWithTotalScore {
survey: Survey
totalScore: Int
}
문항
type Question {
id: ID!
question: String!
choice: [Choice]
}
선택지
type Choice {
id: ID!
text: String!
score: Int!
answer: [Answer]
}
답변
type Answer {
id: ID!
choice: Choice
}
type Query {
getAnswerByQuestionId(questionId: ID!): Answer
getAllAnswer: [Answer]
getAllChoice: [Choice]
getAllChoiceByQuestionId(questionId: ID!): [Choice]
getChoiceByChoiceId(choiceId: ID!): Choice
getAllQuestion: [Question]
getAllQuestionBySurveyId(surveyId: ID): [Question]
getQuestionByQuestionId(questionId: ID): Question
getAllSurvey: [Survey]
getSurveyById(surveyId: ID!): SurveyWithTotalScore
getCompletedSurvey(surveyId: ID!): SurveyWithTotalScore
getTotalScoreBySurveyId(surveyId: ID!): SurveyWithTotalScore
}
type Mutation {
createAnswer(choiceId: ID!): Answer
updateAnswer(answerId: ID!, choiceId: ID!): Answer
deleteAnswer(answerId: ID!): Answer
createChoice(text: String!, score: Int!, questionId: ID!): Choice
updateChoice(text: String!, score: Int!, choiceId: ID!): Choice
deleteChoice(choiceId: ID!): Choice
createQuestion(question: String!, surveyId: ID!): Question
updateQuestion(question: String!, questionId: ID!): Question
deleteQuestion(questionId: ID!): Question
createSurvey(title: String!): Survey
updateSurvey(surveyId: ID!, title: String!): Survey
updateSurveyCompleted(surveyId: ID!): Survey
deleteSurvey(surveyId: ID!): Survey
}
git clone https://github.com/yoonjibin/survey.git
cd your-repo
cp .env.example .env
# Database
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE= {your_database}
DB_USERNAME= {your_username}
DB_PASSWORD= {your_password}
🙏🏻 Postgres에 꼭 DB를 만들어주십쇼.
yarn install
or
npm install
yarn start
or
npm start
http://localhost:4000/graphql 에 접속하여 테스트한다.