Skip to content

Commit a083d69

Browse files
authored
Merge pull request #107 from chenkie/update-prisma
Update to Prisma 2 and Latest Apollo
2 parents c8f36cf + e1b92ec commit a083d69

36 files changed

+23182
-10304
lines changed

package-lock.json

+13,999
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
{
22
"name": "hackernews-react-apollo",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"private": true,
55
"dependencies": {
6-
"apollo-boost": "0.1.4",
7-
"apollo-link-context": "1.0.7",
8-
"apollo-link-ws": "1.0.7",
9-
"graphql": "0.13.1",
10-
"react": "16.2.0",
11-
"react-apollo": "2.1.0",
12-
"react-dom": "16.2.0",
13-
"react-router": "4.2.0",
14-
"react-router-dom": "4.2.2",
15-
"react-scripts": "1.1.1",
16-
"subscriptions-transport-ws": "0.9.7"
6+
"@apollo/client": "^3.2.2",
7+
"graphql": "^15.3.0",
8+
"optimism": "^0.13.0",
9+
"react": "16.13.1",
10+
"react-dom": "16.13.1",
11+
"react-router": "5.2.0",
12+
"react-router-dom": "5.2.0",
13+
"react-scripts": "3.4.3",
14+
"subscriptions-transport-ws": "^0.9.18"
1715
},
1816
"scripts": {
1917
"start": "react-scripts start",
2018
"build": "react-scripts build",
2119
"test": "react-scripts test --env=jsdom",
2220
"eject": "react-scripts eject"
21+
},
22+
"browserslist": {
23+
"production": [
24+
">0.2%",
25+
"not dead",
26+
"not op_mini all"
27+
],
28+
"development": [
29+
"last 1 chrome version",
30+
"last 1 firefox version",
31+
"last 1 safari version"
32+
]
2333
}
2434
}

public/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
-->
1111
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
1212
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
13-
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.2.1/css/tachyons.min.css"/>
13+
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.12.0/css/tachyons.min.css" />
1414
<!--
1515
Notice the use of %PUBLIC_URL% in the tags above.
1616
It will be replaced with the URL of the `public` folder during the build.

server/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# hackernews-graphql-js
2+
3+
This repository contains the final project for the [**GraphQL.js tutorial**](https://www.howtographql.com/graphql-js/0-introduction/) on [How to GraphQL](https://www.howtographql.com/). Note that it also serves as foundation for all frontend tutorials on the site.

server/package.json

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44
"license": "MIT",
55
"scripts": {
66
"start": "node src/index.js",
7-
"prisma": "prisma"
7+
"dev": "nodemon src/index.js"
88
},
99
"dependencies": {
10-
"bcryptjs": "^2.4.3",
11-
"graphql-yoga": "^1.7.0",
12-
"jsonwebtoken": "^8.2.0",
13-
"prisma-client-lib": "^1.31.0"
10+
"@prisma/client": "^2.12.1",
11+
"apollo-server": "^2.19.0",
12+
"bcryptjs": "2.4.3",
13+
"jsonwebtoken": "8.5.1"
1414
},
1515
"devDependencies": {
16-
"prisma": "^1.31.0"
16+
"@prisma/cli": "^2.12.1",
17+
"nodemon": "^2.0.6"
1718
}
1819
}

server/prisma/datamodel.prisma

-23
This file was deleted.

server/prisma/dev.db

48 KB
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Migration `20201125185150-init`
2+
3+
This migration has been generated by Ryan Chenkie at 11/25/2020, 1:51:50 PM.
4+
You can check out the [state of the schema](./schema.prisma) after the migration.
5+
6+
## Database Steps
7+
8+
```sql
9+
CREATE TABLE "Link" (
10+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
11+
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
12+
"description" TEXT NOT NULL,
13+
"url" TEXT NOT NULL,
14+
"postedById" INTEGER NOT NULL,
15+
16+
FOREIGN KEY ("postedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
17+
)
18+
19+
CREATE TABLE "User" (
20+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
21+
"name" TEXT NOT NULL,
22+
"email" TEXT NOT NULL,
23+
"password" TEXT NOT NULL
24+
)
25+
26+
CREATE TABLE "Vote" (
27+
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
28+
"linkId" INTEGER NOT NULL,
29+
"userId" INTEGER NOT NULL,
30+
31+
FOREIGN KEY ("linkId") REFERENCES "Link"("id") ON DELETE CASCADE ON UPDATE CASCADE,
32+
FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE
33+
)
34+
35+
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email")
36+
37+
CREATE UNIQUE INDEX "Vote.linkId_userId_unique" ON "Vote"("linkId", "userId")
38+
```
39+
40+
## Changes
41+
42+
```diff
43+
diff --git schema.prisma schema.prisma
44+
migration ..20201125185150-init
45+
--- datamodel.dml
46+
+++ datamodel.dml
47+
@@ -1,0 +1,37 @@
48+
+datasource db {
49+
+ provider = "sqlite"
50+
+ url = "***"
51+
+}
52+
+
53+
+generator client {
54+
+ provider = "prisma-client-js"
55+
+}
56+
+
57+
+model Link {
58+
+ id Int @id @default(autoincrement())
59+
+ createdAt DateTime @default(now())
60+
+ description String
61+
+ url String
62+
+ postedBy User @relation(fields: [postedById], references: [id])
63+
+ postedById Int
64+
+ votes Vote[]
65+
+}
66+
+
67+
+model User {
68+
+ id Int @id @default(autoincrement())
69+
+ name String
70+
+ email String @unique
71+
+ password String
72+
+ links Link[]
73+
+ votes Vote[]
74+
+}
75+
+
76+
+model Vote {
77+
+ id Int @id @default(autoincrement())
78+
+ link Link @relation(fields: [linkId], references: [id])
79+
+ linkId Int
80+
+ user User @relation(fields: [userId], references: [id])
81+
+ userId Int
82+
+
83+
+ @@unique([linkId, userId])
84+
+}
85+
```
86+
87+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
datasource db {
2+
provider = "sqlite"
3+
url = "***"
4+
}
5+
6+
generator client {
7+
provider = "prisma-client-js"
8+
}
9+
10+
model Link {
11+
id Int @id @default(autoincrement())
12+
createdAt DateTime @default(now())
13+
description String
14+
url String
15+
postedBy User @relation(fields: [postedById], references: [id])
16+
postedById Int
17+
votes Vote[]
18+
}
19+
20+
model User {
21+
id Int @id @default(autoincrement())
22+
name String
23+
email String @unique
24+
password String
25+
links Link[]
26+
votes Vote[]
27+
}
28+
29+
model Vote {
30+
id Int @id @default(autoincrement())
31+
link Link @relation(fields: [linkId], references: [id])
32+
linkId Int
33+
user User @relation(fields: [userId], references: [id])
34+
userId Int
35+
36+
@@unique([linkId, userId])
37+
}

0 commit comments

Comments
 (0)