https://github.com/raulpe7eira/book-exercises-graphql
Book exercises
https://github.com/raulpe7eira/book-exercises-graphql
apollo-graphql book bootstrap4 graphql http-server javascript learn nodejs nodemon prisma
Last synced: about 1 month ago
JSON representation
Book exercises
- Host: GitHub
- URL: https://github.com/raulpe7eira/book-exercises-graphql
- Owner: raulpe7eira
- Created: 2020-01-15T22:10:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-01-15T22:23:41.000Z (over 6 years ago)
- Last Synced: 2025-08-12T09:31:55.542Z (10 months ago)
- Topics: apollo-graphql, book, bootstrap4, graphql, http-server, javascript, learn, nodejs, nodemon, prisma
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# book-exercises-graphql
Exercises of [GraphQL Book](https://www.casadocodigo.com.br/products/livro-graphql):

## Stack
- [Prisma](https://www.prisma.io/)
- [Node.js](https://nodejs.org)
- [Apollo GraphQL](https://www.apollographql.com/)
- [Nodemon](https://nodemon.io/)
- [Bootstrap](https://getbootstrap.com/)
- [Http-server](https://github.com/http-party/http-server)
## Service
### graphql-prisma
> Online backend service
1. Installs and inits new prisma project
```bash
npm i -g prisma
prisma init graphql-prisma
```
2. Chooses _Demo server_
3. Changes _datamodel.prisma_ content with:
```graphql
type Aluno {
id: ID! @id
nomeCompleto: String!
idade: Int
curso: Curso
}
type Curso {
id: ID! @id
disciplina: String!
alunos: [Aluno!]!
}
```
4. Deploys
```bash
prisma deploy
```
### graphql-backend
> Local backend service
```bash
npm install
npm install -g nodemon
nodemon server.js
```
### graphql-frontend
> Frontend service
```bash
npm install http-server -g
http-server .\
```
#### Setup
- Uses online backend
1. Gets endpoint
```bash
prisma info
```
2. Sets endpoint in _scripts.js_
```javascript
endpoint: 'https://eu1.prisma.sh/raul-pereira-29c5b0/graphql-prisma/dev',
wsConnection: new WebSocket(
'wss://eu1.prisma.sh/raul-pereira-29c5b0/graphql-prisma/dev',
'graphql-subscriptions'
),
```
- Uses local backend
1. Sets endpoint in _scripts.js_
```javascript
endpoint: 'http://localhost:3000',
wsConnection: new WebSocket(
'wss://localhost:3000/graphql',
'graphql-subscriptions'
),
```