Skip to content

Commit

Permalink
Prisma와 node 서버의 연동작업 및 Prisma Client Generator 작업
Browse files Browse the repository at this point in the history
  • Loading branch information
thekanon committed Nov 19, 2020
1 parent 59be18d commit 0425fe7
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 1 deletion.
5 changes: 4 additions & 1 deletion package.json
Expand Up @@ -18,6 +18,9 @@
"nodemon": "^2.0.6"
},
"scripts": {
"dev": "nodemon --exec babel-node src/server.js"
"dev": "nodemon --exec babel-node src/server.js",
"generate": "prisma generate",
"deploy": "prisma deploy",
"prisma": "yarn run deploy && yarn run generate"
}
}
3 changes: 3 additions & 0 deletions src/api/User/allUser/allUser.graphql
@@ -0,0 +1,3 @@
type Query {
allUser: [User!]!
}
8 changes: 8 additions & 0 deletions src/api/User/allUser/allUser.js
@@ -0,0 +1,8 @@
import {prisma} from "../../../../generated/prisma-client"
export default {
Query:{
allUser: async() => {
return await prisma.users()
}
}
}
5 changes: 5 additions & 0 deletions src/api/User/getUser/getUser.graphql
@@ -0,0 +1,5 @@
type Query {
getUser(
id:String!
): User
}
8 changes: 8 additions & 0 deletions src/api/User/getUser/getUser.js
@@ -0,0 +1,8 @@
import {prisma} from "../../../../generated/prisma-client"
export default {
Query:{
getUser: async(_, args) => {
return await prisma.user({ id: args.id });
}
}
}
41 changes: 41 additions & 0 deletions src/api/model.graphql
@@ -0,0 +1,41 @@
type User {
id: ID!
username: String!
email: String!
votes: [Vote]
}

type Vote {
id: ID!
title : String!
description : String!
upperVote:[Vote!]!
lowerVote:[Vote!]!
val1: String
val2: String
val3: String
val4: String
val5: String
val6: String
val7: String
val8: String
val9: String
val10: String
val11: String
val12: String
val13: String
val14: String
val15: String
val16: String
val17: String
val18: String
val19: String
val20: String
}

type UserVote {
id: ID!
user:User!
vote: Vote!
voteSelect: String!
}

0 comments on commit 0425fe7

Please sign in to comment.