-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
136 additions
and
65 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// This is your Prisma schema file, | ||
// learn more about it in the docs: https://pris.ly/d/prisma-schema | ||
|
||
datasource db { | ||
provider = "sqlite" | ||
url = "file:./dev.db" | ||
} | ||
|
||
generator client { | ||
provider = "prisma-client-js" | ||
} | ||
|
||
model Link { | ||
id String @id @default(cuid()) | ||
description String | ||
url String | ||
createdAt DateTime @default(now()) | ||
postedBy User @relation(fields: [userId], references: [id]) | ||
votes Vote[] | ||
userId String | ||
} | ||
|
||
model User { | ||
id String @id @default(cuid()) | ||
name String | ||
email String | ||
password String | ||
links Link[] | ||
votes Vote[] | ||
} | ||
|
||
model Vote { | ||
id String @id @default(cuid()) | ||
link Link @relation(fields: [linkId], references: [id]) | ||
user User @relation(fields: [userId], references: [id]) | ||
linkId String | ||
userId String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
const { GraphQLServer } = require('graphql-yoga') | ||
const { prisma } = require('./generated/prisma-client') | ||
const Query = require('./resolvers/Query') | ||
const Mutation = require('./resolvers/Mutation') | ||
const Subscription = require('./resolvers/Subscription') | ||
const User = require('./resolvers/User') | ||
const Link = require('./resolvers/Link') | ||
const Vote = require('./resolvers/Vote') | ||
import { ApolloServer } from 'apollo-server'; | ||
import { PrismaClient } from '@prisma/client'; | ||
import * as resolvers from './resolvers'; | ||
|
||
const resolvers = { | ||
Query, | ||
Mutation, | ||
Subscription, | ||
User, | ||
Link, | ||
Vote, | ||
} | ||
const prisma = new PrismaClient(); | ||
|
||
const server = new GraphQLServer({ | ||
const server = new ApolloServer({ | ||
typeDefs: './src/schema.graphql', | ||
resolvers, | ||
context: request => ({ | ||
...request, | ||
prisma, | ||
}), | ||
}) | ||
server.start(() => console.log(`Server is running on http://localhost:4000`)) | ||
context: () => ({ | ||
prisma | ||
}) | ||
}); | ||
|
||
server.listen().then(({ port }) => { | ||
console.log( | ||
`Server listening on http://localhost:${port}` | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * as Link from './Link'; | ||
export * as Mutation from './Mutation'; | ||
export * as Query from './Query'; | ||
export * as Subscription from './Subscription'; | ||
export * as User from './User'; | ||
export * as Vote from './Vote'; |