-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Upgrading dependencies * upgrade prisma setup starting in section 2 * section 2: separate into trello rest proxy 2.4 and prisma setup 2.5 * section 3 and section 4: clean up server and upgrade to latest prisma version * section 5: clean up server and upgrade to latest prisma version * section 6: upgrade server part, including upgrading to latest prisma version * section 7: upgrade server part, including upgrading to latest prisma version * remove yarn.lock files * section 6-7: remove workaround for prisma issue 2225 * section 2: upgrade server dependencies * section 2: migrate to latest apollo-server v2 * section 6-7: server: fix resolvers, use correct graphql library
- Loading branch information
Showing
65 changed files
with
1,215 additions
and
13,274 deletions.
There are no files selected for viewing
File renamed without changes.
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 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,61 +1,18 @@ | ||
# Local GraphQL server based on Prisma | ||
|
||
To run you local server, you will have to run these commands in a | ||
terminal in this sub-folder (after a `cd server`). | ||
terminal in this sub-folder (after a `cd server`): | ||
|
||
First, you can startup the local database prisma server with `docker-compose up`. | ||
* After having docker running on you local machine, | ||
you can **start up** the prisma server with `docker-compose up -d`. | ||
|
||
After the usual `npm install` or `yarn`, the prisma tooling is available and can be used with `npx prisma ...`: | ||
* By running `npm install` or `yarn`, the prisma tooling will be installed and available in the next step: | ||
|
||
`npx prisma deploy` | ||
|
||
|
||
After having docker started on you local machine and running `docker-compose up`, | ||
you then run `npx prisma deploy` to deploy the schema to the local (mysql) database. | ||
|
||
Check it by opening this page in your browser: [http://localhost:4466/CoolBoardDB/dev](http://localhost:4466/CoolBoardDB/dev) | ||
|
||
|
||
# Trello-REST-Api wrapper - quick start | ||
|
||
To run you local server, you will have to run these commands in a | ||
terminal in this sub-folder (after a `cd server`). | ||
|
||
Then you will first to install all libraries per `npm install` or `yarn`. | ||
|
||
## run apollo-express-server | ||
|
||
```bash | ||
yarn run start | ||
``` | ||
and [open graphiql](http://localhost:3000/graphiql?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%7B%0A%20%20%20%20id%0A%20%20%20%20url%0A%20%20%20%20username%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) | ||
|
||
## run express-graphql | ||
|
||
```bash | ||
yarn run start-express | ||
``` | ||
and [open graphiql](http://localhost:4000/?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%0A%20%20%7B%0A%20%20%20%20id%0A%20%20%20%20username%0A%20%20%20%20url%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A) | ||
|
||
## run graphql-yoga | ||
```bash | ||
yarn run start-yoga | ||
``` | ||
and [open graphcool playground](http://localhost:4000/) | ||
|
||
You can for example run this query: | ||
``` | ||
{ | ||
Member(username:"taco") | ||
{ | ||
id | ||
username | ||
url | ||
boards { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
* You then run `npx prisma deploy` to **deploy the schema**. | ||
|
||
* Finally, **check** it by opening this page: [http://localhost:4466/](http://localhost:4466/) which shows the graphiql or graphql playground. | ||
--- | ||
* Later, you can **stop** the prisma server via `docker-compose stop` , | ||
`docker-compose kill` , | ||
|
||
* For **completely removing** these docker containers you will need to run `docker-compose kill` and `docker-compose rm` which will destroy all its stored data! |
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,58 @@ | ||
# Trello-REST-Api wrapper - quick start | ||
|
||
To run you local server, you will have to run these commands in a | ||
terminal in this sub-folder (after a `cd server`). | ||
|
||
You will first need to install all libraries per `npm install` or `yarn`. | ||
|
||
## run apollo-express-server | ||
|
||
```bash | ||
yarn run start | ||
``` | ||
and open [http://localhost:3000/graphiql](http://localhost:3000/graphiql?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%7B%0A%20%20%20%20id%0A%20%20%20%20url%0A%20%20%20%20username%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) | ||
for this query: | ||
``` | ||
{ | ||
Member(username:"taco") { | ||
id | ||
url | ||
username | ||
boards { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## run express-graphql | ||
|
||
```bash | ||
yarn run start-express | ||
``` | ||
and open [http://localhost:4000](http://localhost:4000/?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%0A%20%20%7B%0A%20%20%20%20id%0A%20%20%20%20username%0A%20%20%20%20url%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A) | ||
|
||
## run graphql-yoga | ||
```bash | ||
yarn run start-yoga | ||
``` | ||
and open [http://localhost:4000](http://localhost:4000/?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%7B%0A%20%20%20%20id%0A%20%20%20%20url%0A%20%20%20%20username%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) playground | ||
|
||
|
||
You can for example run this query: | ||
``` | ||
{ | ||
Member(username:"taco") | ||
{ | ||
id | ||
username | ||
url | ||
boards { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
|
8 changes: 4 additions & 4 deletions
8
Section2/server/datamodel.graphql → Section2/server/datamodel.prisma
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 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,33 @@ | ||
version: '3' | ||
services: | ||
prisma-handson-course: | ||
image: prismagraphql/prisma:1.31 | ||
restart: always | ||
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-handson-course | ||
user: root | ||
password: prisma | ||
rawAccess: true | ||
port: 3306 | ||
migrations: true | ||
mysql-handson-course: | ||
image: mysql:5.7 | ||
restart: always | ||
# Uncomment the next two lines to connect to your your database from outside the Docker environment, e.g. using a database GUI like Workbench | ||
# ports: | ||
# - "3306:3306" | ||
environment: | ||
MYSQL_ROOT_PASSWORD: prisma | ||
volumes: | ||
- mysql:/var/lib/mysql | ||
volumes: | ||
mysql: |
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 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,9 +1,8 @@ | ||
service: CoolBoardDB | ||
stage: dev | ||
endpoint: http://localhost:4466 | ||
|
||
datamodel: datamodel.graphql | ||
datamodel: datamodel.prisma | ||
|
||
generate: | ||
- generator: graphql-schema | ||
output: schema.graphql | ||
|
||
# to enable auth, provide | ||
# secret: my-secret | ||
disableAuth: true | ||
cluster: local |
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,36 +1,22 @@ | ||
import express from 'express'; | ||
import bodyParser from 'body-parser'; | ||
|
||
import { | ||
graphqlExpress, | ||
graphiqlExpress} from 'apollo-server-express'; | ||
const {ApolloServer, gql} = require('apollo-server-express'); | ||
|
||
import {schema} from './schema'; | ||
|
||
const PORT = 3000; | ||
|
||
const server = express(); | ||
|
||
server.use('/graphql', | ||
bodyParser.json(), | ||
graphqlExpress({ | ||
schema, | ||
tracing: false, | ||
} | ||
)); | ||
|
||
server.use('/graphiql', | ||
graphiqlExpress({ | ||
endpointURL: '/graphql', | ||
query: ``, | ||
})); | ||
const apolloServer = new ApolloServer({ schema, | ||
debug: true, | ||
tracing: true, | ||
playground: true | ||
}); | ||
|
||
server.listen(PORT, () => { | ||
console.log( | ||
`GraphQL Server is now running on | ||
http://localhost:${PORT}/graphql`); | ||
apolloServer.applyMiddleware({ | ||
path: '/graphql', | ||
app: server }); | ||
|
||
console.log( | ||
`View GraphiQL at | ||
http://localhost:${PORT}/graphiql`); | ||
}); | ||
server.listen({ port: PORT }, () => console.log(`GraphQL Server is now running on http://localhost:${PORT}${apolloServer.graphqlPath}`) | ||
) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,58 +1,18 @@ | ||
# Local GraphQL server based on Prisma | ||
# Local GraphQL server based on Prisma | ||
|
||
To run you local server, you will have to run these commands in a | ||
terminal in this sub-folder (after a `cd server`). | ||
terminal in this sub-folder (after a `cd server`): | ||
|
||
Then you will first need to install this library **global** via | ||
`npm install -g prisma@1.5.3` or | ||
`yarn global add prisma@1.5.3`. | ||
* After having docker running on you local machine, | ||
you can **start up** the prisma server with `docker-compose up -d`. | ||
|
||
After having docker started on you local machine and running `prisma local start`, | ||
you then run `prisma deploy` and deploy it _locally_. | ||
* By running `npm install` or `yarn`, the prisma tooling will be installed and available in the next step: | ||
|
||
Check it by opening this page in your browser: [http://localhost:4466/CoolBoardDB/dev](http://localhost:4466/CoolBoardDB/dev) | ||
|
||
|
||
# Trello-REST-Api wrapper - quick start | ||
|
||
To run you local server, you will have to run these commands in a | ||
terminal in this sub-folder (after a `cd server`). | ||
|
||
Then you will first to install all libraries per `npm install` or `yarn`. | ||
|
||
## run apollo-express-server | ||
|
||
```bash | ||
yarn run start | ||
``` | ||
and [open graphiql](http://localhost:3000/graphiql?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%7B%0A%20%20%20%20id%0A%20%20%20%20url%0A%20%20%20%20username%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D) | ||
|
||
## run express-graphql | ||
|
||
```bash | ||
yarn run start-express | ||
``` | ||
and [open graphiql](http://localhost:4000/?query=%7B%0A%20%20Member(username%3A%22taco%22)%20%0A%20%20%7B%0A%20%20%20%20id%0A%20%20%20%20username%0A%20%20%20%20url%0A%20%20%20%20boards%20%7B%0A%20%20%20%20%20%20id%0A%20%20%20%20%20%20name%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D%0A) | ||
|
||
## run graphql-yoga | ||
```bash | ||
yarn run start-yoga | ||
``` | ||
and [open graphcool playground](http://localhost:4000/) | ||
|
||
You can for example run this query: | ||
``` | ||
{ | ||
Member(username:"taco") | ||
{ | ||
id | ||
username | ||
url | ||
boards { | ||
id | ||
name | ||
} | ||
} | ||
} | ||
``` | ||
* You then run `npx prisma deploy` to **deploy the schema**. | ||
|
||
* Finally, **check** it by opening this page: [http://localhost:4466/](http://localhost:4466/) which shows the graphiql or graphql playground. | ||
--- | ||
* Later, you can **stop** the prisma server via `docker-compose stop` , | ||
`docker-compose kill` , | ||
|
||
* For **completely removing** these docker containers you will need to run `docker-compose kill` and `docker-compose rm` which will destroy all its stored data! |
Oops, something went wrong.