Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Material ui #81

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
6ca3f1d
Initial commit
cangoektas Nov 25, 2018
1a4a0c7
Rename app to app-final
cangoektas Dec 1, 2018
6afece0
Make app prettier
cangoektas Dec 1, 2018
32c6eed
Add app directory
cangoektas Dec 2, 2018
c6386e8
Use App.js from the tutorial
cangoektas Dec 3, 2018
742bfbd
initial
zwhitchcox Feb 2, 2019
67b349c
pages skeleton
zwhitchcox Feb 2, 2019
47c5bde
deploy
zwhitchcox Feb 8, 2019
74f83ed
project name on windows
zwhitchcox Feb 8, 2019
9bf0161
proj name replace
zwhitchcox Feb 8, 2019
b8f80f0
doat
zwhitchcox Feb 8, 2019
41c37b3
remove stuff from hep
zwhitchcox Feb 9, 2019
944f040
style
zwhitchcox Feb 26, 2019
69b75a3
eggshell
zwhitchcox Mar 27, 2019
038234b
port and delete-old
zwhitchcox Mar 27, 2019
a69e2e2
conflicts
zwhitchcox Mar 27, 2019
956356d
dist folder
zwhitchcox Mar 27, 2019
e0e4ef8
delete hello
zwhitchcox Mar 27, 2019
6c2207a
Add new directory
zwhitchcox Mar 27, 2019
ba7ab68
set docker path
zwhitchcox Mar 27, 2019
0fcb4bc
set docker path
zwhitchcox Mar 27, 2019
c9e5489
staging and prod
zwhitchcox Mar 27, 2019
accb043
??
zwhitchcox Mar 28, 2019
fc1eb54
move webpack config
zwhitchcox Mar 29, 2019
a0b4509
form
zwhitchcox Mar 29, 2019
604cc1e
sample
zwhitchcox Mar 29, 2019
05a4cb3
Form Red Label
zwhitchcox Mar 29, 2019
ca239ce
Server restarts automatically on change
zwhitchcox Mar 29, 2019
3c5aa9b
react-router
zwhitchcox Mar 29, 2019
062e0f4
SPA
zwhitchcox Mar 29, 2019
f7f1879
change name
zwhitchcox Mar 29, 2019
3485b27
remove terser
zwhitchcox Mar 30, 2019
8ef88a1
remove all files
zwhitchcox Apr 1, 2019
17258ac
Merge branch 'master' of https://github.com/cangoektas/prisma-react-f…
zwhitchcox Apr 1, 2019
51e3e82
basic app
zwhitchcox Apr 1, 2019
b0ed4c4
React Router
zwhitchcox Apr 1, 2019
90ecbe0
???
zwhitchcox Apr 6, 2019
f632db1
switch to hooks
zwhitchcox Apr 6, 2019
ab9bca0
more hooks
zwhitchcox Apr 6, 2019
bd4f871
switch back to default
zwhitchcox Apr 6, 2019
805b8b9
hackernews
zwhitchcox Apr 6, 2019
8f5b537
sign in and sign up moved to material-ui
zwhitchcox Apr 7, 2019
58b3446
navbar material ui
zwhitchcox Apr 7, 2019
2dcaa84
navbar sign in/out/up material-ui
zwhitchcox Apr 7, 2019
839d0ab
material-ui list
zwhitchcox Apr 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ graphql.schema.json
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package.json
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"files.exclude": {
"__error": "Not found",
"dist": true,
"node_modules": true,
"yarn-error.log": true,
"workspace.code-workspace": true,
"yarn.lock": true,
"build": true,
".vscode": true,
"app\\node_modules": true,
"server\\yarn.lock": true,
"server\\node_modules": true
}
}
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: start-everything-local
start-everything-local:
docker-machine start default
docker-compose up -d -f server/docker-compose-yml
91 changes: 0 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,91 +0,0 @@
# React & Apollo Tutorial

This is the sample project that belongs to the [React & Apollo Tutorial](https://www.howtographql.com/react-apollo/0-introduction/) on How to GraphQL.

## How to use

### 1. Clone repository

```sh
git clone https://github.com/howtographql/react-apollo/
```

### 2. Install dependencies & Deploy the Prisma database API

To install the Prisma CLI globally with Yarn, use the following command:
```sh
yarn global add prisma
```

Also, run the following commands:
```sh
cd react-apollo/server
yarn install
prisma deploy
```

Then, follow these steps in the interactive CLI wizard:

1. Select **Demo server**
1. **Authenticate** with Prisma Cloud in your browser (if necessary)
1. Back in your terminal, **confirm all suggested values**

<details>
<summary>Alternative: Run Prisma locally via Docker</summary>

1. Ensure you have Docker installed on your machine. If not, you can get it from [here](https://store.docker.com/search?offering=community&type=edition).
1. Create `docker-compose.yml` for MySQL (see [here](https://www.prisma.io/docs/prisma-server/database-connector-POSTGRES-jgfr/) for Postgres):
```yml
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.23
restart: always
ports:
- "4466:4466"
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
migrations: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- mysql:/var/lib/mysql
volumes:
mysql:
```
1. Run `docker-compose up -d`
1. Run `prisma deploy`

</details>

### 3. Start the server

To start the server, all you need to do is execute the `start` script by running the following command inside the `server` directory:

```sh
yarn start
```

> **Note**: If you want to interact with the GraphQL API of the server inside a [GraphQL Playground](https://github.com/prisma/graphql-playground), you can navigate to [http://localhost:4000](http://localhost:4000).

### 4. Run the app

Now that the server is running, you can start the React app as well. The commands need to be run in a new terminal tab/window inside the root directory `react-apollo` (because the current tab is blocked by the process running the server):

```sh
yarn install
yarn start
```

You can now open your browser and use the app on [http://localhost:3000](http://localhost:3000).
Empty file added dist/.gitkeep
Empty file.
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,33 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^3.9.3",
"@material-ui/icons": "^3.0.2",
"apollo-boost": "0.1.4",
"apollo-link-context": "1.0.7",
"apollo-link-ws": "1.0.7",
"classnames": "^2.2.6",
"graphql": "0.13.1",
"react": "16.2.0",
"react": "16.8.4",
"react-apollo": "2.1.0",
"react-dom": "16.2.0",
"react-router": "4.2.0",
"react-router-dom": "4.2.2",
"react-scripts": "1.1.1",
"react-dom": "16.8.4",
"react-hanger": "^1.1.4",
"react-router": "^5.0.0",
"react-router-dom": "^5.0.0",
"react-scripts": "2.1.8",
"react-use-form-state": "^0.9.0",
"subscriptions-transport-ws": "0.9.7"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.2.1/css/tachyons.min.css"/>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"devDependencies": {
"prisma": "^1.23.0"
}
}
}
29 changes: 29 additions & 0 deletions server/prisma/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'
services:
prisma:
image: prismagraphql/prisma:1.20
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
port: 4466
# uncomment the next line and provide the env var PRISMA_MANAGEMENT_API_SECRET=my-secret to activate cluster security
managementApiSecret: my-secret
databases:
default:
connector: mysql
host: mysql
port: 3306
user: root
password: prisma
migrations: true
rawAccess: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- mysql:/var/lib/mysql
volumes:
mysql:
7 changes: 5 additions & 2 deletions server/prisma/prisma.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Specifies the HTTP endpoint of your Prisma API.
endpoint: ''
endpoint: 'http://192.168.99.100:4466'

# Defines your models, each model is mapped to the database as a table.
datamodel: datamodel.prisma
Expand All @@ -12,4 +12,7 @@ generate:
# Ensures Prisma client is re-generated after a datamodel change.
hooks:
post-deploy:
- prisma generate
- prisma generate

seed:
run: node ./prisma/seed.js
70 changes: 70 additions & 0 deletions server/prisma/seed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
const {prisma} = require('../src/generated/prisma-client')
const bcrypt = require('bcryptjs')

async function main() {
const password = await bcrypt.hash('password', 10)
await prisma.createUser({
email: 'jamesfranco@gmail.com',
name: 'James Franco',
password,
links: {
create: [
{
url: 'https://www.google.com',
description: 'Search Engine',
},
{
url: 'https://www.twitter.com',
description: 'Social Network Twitter',
},
{
url: 'https://www.facebook.com',
description: 'Social Network Facebook',
},
{
url: 'https://www.reddit.com',
description: 'Like hacker news reddit',
},
{
url: 'https://www.news.ycombinator.com',
description: 'Like this website hacker news',
},
{
url: 'https://www.react.com',
description: 'front end functional - React',
},
]
}
})
await prisma.createUser({
name: 'Jason Segel',
email: "jasonsegel@gmail.com",
password,
links: {
create: [
{
url: 'https://www.vuejs.org',
description: 'apparently successor to react',
},
{
url: 'https://elixir-lang.org',
description: 'Elixir',
},
{
url: 'https://www.elm-lang.org',
description: 'Elm',
},
{
url: 'https://www.craiglist.org',
description: 'Craigslist',
},
{
url: 'https://ebay.com',
description: 'Ebay',
},
]
}
})
}

main()
17 changes: 1 addition & 16 deletions server/src/generated/prisma-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,6 @@ var models = [
exports.Prisma = prisma_lib_1.makePrismaClientClass({
typeDefs,
models,
endpoint: ``,
secret: `mysecret123`
endpoint: `http://192.168.99.100:4466`
});
exports.prisma = new exports.Prisma();
var models = [
{
name: "Link",
embedded: false
},
{
name: "User",
embedded: false
},
{
name: "Vote",
embedded: false
}
];
5 changes: 3 additions & 2 deletions server/src/resolvers/Mutation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function post(parent, args, context) {
return context.prisma.createLink({
url: args.url,
description: args.description,
postedBy: { connect: { id: userId } },
})
}

Expand All @@ -21,7 +22,7 @@ async function signup(parent, args, context) {
}
}

async function login(parent, args, context) {
async function signin(parent, args, context) {
const user = await context.prisma.user({ email: args.email })
if (!user) {
throw new Error('No such user found')
Expand Down Expand Up @@ -57,6 +58,6 @@ async function vote(parent, args, context) {
module.exports = {
post,
signup,
login,
signin,
vote,
}
2 changes: 1 addition & 1 deletion server/src/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Feed {
type Mutation {
post(url: String!, description: String!): Link!
signup(email: String!, password: String!, name: String!): AuthPayload
login(email: String!, password: String!): AuthPayload
signin(email: String!, password: String!): AuthPayload
vote(linkId: ID!): Vote!
}

Expand Down
Loading