File tree Expand file tree Collapse file tree 8 files changed +136
-65
lines changed Expand file tree Collapse file tree 8 files changed +136
-65
lines changed Original file line number Diff line number Diff line change 7
7
"prisma" : " prisma"
8
8
},
9
9
"dependencies" : {
10
+ "@prisma/client" : " ^2.8.0" ,
11
+ "apollo-server" : " ^2.18.2" ,
10
12
"bcryptjs" : " ^2.4.3" ,
11
- "graphql-yoga" : " ^1.7.0" ,
12
- "jsonwebtoken" : " ^8.2.0" ,
13
- "prisma-client-lib" : " ^1.31.0"
13
+ "jsonwebtoken" : " ^8.2.0"
14
14
},
15
15
"devDependencies" : {
16
- "prisma" : " ^1.31 .0"
16
+ "@ prisma/cli " : " ^2.8 .0"
17
17
}
18
18
}
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ // This is your Prisma schema file,
2
+ // learn more about it in the docs: https://pris.ly/d/prisma-schema
3
+
4
+ datasource db {
5
+ provider = " sqlite "
6
+ url = " file:./dev.db "
7
+ }
8
+
9
+ generator client {
10
+ provider = " prisma-client-js "
11
+ }
12
+
13
+ model Link {
14
+ id String @id @default (cuid () )
15
+ description String
16
+ url String
17
+ createdAt DateTime @default (now () )
18
+ postedBy User @relation (fields : [userId ] , references : [id ] )
19
+ votes Vote []
20
+ userId String
21
+ }
22
+
23
+ model User {
24
+ id String @id @default (cuid () )
25
+ name String
26
+ email String
27
+ password String
28
+ links Link []
29
+ votes Vote []
30
+ }
31
+
32
+ model Vote {
33
+ id String @id @default (cuid () )
34
+ link Link @relation (fields : [linkId ] , references : [id ] )
35
+ user User @relation (fields : [userId ] , references : [id ] )
36
+ linkId String
37
+ userId String
38
+ }
Original file line number Diff line number Diff line change 1
- const { GraphQLServer } = require ( 'graphql-yoga' )
2
- const { prisma } = require ( './generated/prisma-client' )
3
- const Query = require ( './resolvers/Query' )
4
- const Mutation = require ( './resolvers/Mutation' )
5
- const Subscription = require ( './resolvers/Subscription' )
6
- const User = require ( './resolvers/User' )
7
- const Link = require ( './resolvers/Link' )
8
- const Vote = require ( './resolvers/Vote' )
1
+ import { ApolloServer } from 'apollo-server' ;
2
+ import { PrismaClient } from '@prisma/client' ;
3
+ import * as resolvers from './resolvers' ;
9
4
10
- const resolvers = {
11
- Query,
12
- Mutation,
13
- Subscription,
14
- User,
15
- Link,
16
- Vote,
17
- }
5
+ const prisma = new PrismaClient ( ) ;
18
6
19
- const server = new GraphQLServer ( {
7
+ const server = new ApolloServer ( {
20
8
typeDefs : './src/schema.graphql' ,
21
9
resolvers,
22
- context : request => ( {
23
- ...request ,
24
- prisma,
25
- } ) ,
26
- } )
27
- server . start ( ( ) => console . log ( `Server is running on http://localhost:4000` ) )
10
+ context : ( ) => ( {
11
+ prisma
12
+ } )
13
+ } ) ;
14
+
15
+ server . listen ( ) . then ( ( { port } ) => {
16
+ console . log (
17
+ `Server listening on http://localhost:${ port } `
18
+ ) ;
19
+ } ) ;
Original file line number Diff line number Diff line change
1
+ export * as Link from './Link' ;
2
+ export * as Mutation from './Mutation' ;
3
+ export * as Query from './Query' ;
4
+ export * as Subscription from './Subscription' ;
5
+ export * as User from './User' ;
6
+ export * as Vote from './Vote' ;
You can’t perform that action at this time.
0 commit comments