mirror of
https://github.com/aljazceru/landscape-template.git
synced 2025-12-27 03:04:24 +01:00
voting resolve and prisma seed and cleanup
This commit is contained in:
@@ -14,7 +14,16 @@ module.exports = {
|
||||
});
|
||||
},
|
||||
},
|
||||
//Mutation: {
|
||||
// vote: async (_source, args, context) => {},
|
||||
//},
|
||||
Mutation: {
|
||||
vote: async (_source, args, context) => {
|
||||
const project = await context.prisma.project.findUnique({where: { id: args.project_id }});
|
||||
console.log(project)
|
||||
return context.prisma.vote.create({
|
||||
data: {
|
||||
project_id: project.id,
|
||||
amount_in_sat: args.amount_in_sat,
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -16,9 +16,20 @@ module.exports = gql`
|
||||
title: String!
|
||||
}
|
||||
|
||||
type Vote {
|
||||
id: Int!
|
||||
project: Project!
|
||||
amount_in_sat: Int!
|
||||
payment_request: String!
|
||||
paid: Boolean!
|
||||
}
|
||||
|
||||
type Query {
|
||||
allProjects: [Project]!
|
||||
getProject(id: Int!): Project
|
||||
allCategories: [Category]!
|
||||
}
|
||||
type Mutation {
|
||||
vote (project_id: Int!, amount_in_sat: Int!): Vote!
|
||||
}
|
||||
`;
|
||||
|
||||
@@ -45,6 +45,9 @@
|
||||
"storybook": "start-storybook -p 6006 -s public",
|
||||
"build-storybook": "build-storybook -s public"
|
||||
},
|
||||
"prisma": {
|
||||
"seed": "node prisma/seed.js"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"react-app",
|
||||
|
||||
28
prisma/seed.js
Normal file
28
prisma/seed.js
Normal file
@@ -0,0 +1,28 @@
|
||||
const { PrismaClient } = require('@prisma/client')
|
||||
const prisma = new PrismaClient()
|
||||
|
||||
async function main() {
|
||||
const category = await prisma.category.create({
|
||||
data: {
|
||||
title: 'El Salvador',
|
||||
},
|
||||
});
|
||||
|
||||
const project = await prisma.project.create({
|
||||
data: {
|
||||
title: "Captain Morgan",
|
||||
description: "HQ on a VULCANO lake",
|
||||
website: "https://github.com/peakshift",
|
||||
category_id: category.id,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
})
|
||||
.finally(async () => {
|
||||
await prisma.$disconnect()
|
||||
})
|
||||
Reference in New Issue
Block a user