This server was intended as a supporting backend service for the Table Football React Web App front-end project I made earlier. Both are still work in progress, the master
-branch contains the stable version of the project.
Run all the terminal commands within the project root directory.
This Project was developed using Node v8.11.3. (see https://nodejs.org for how to setup Node)
$ sudo npm i -g npm@latest
$ sudo npm i -g prisma@ graphql-cli
$ npm i
See Docker for easy setup instructions for Mac & Windows users (https://www.docker.com/get-started).
Auto-detected by script:
$ curl -fsSL get.docker.com -o get-docker.sh && sh det-docker.sh
(Note: Verify that https://get.docker.com is the same script as install.sh
at https://github.com/docker/docker-install before you run this command).
Ubuntu:
$ apt-get update && apt-get upgrade && apt-get install docker python-pip && pip install docker-compose
Alpine Linux:
$ apk update && apk upgrade && apk add docker py-pip && pip install docker-compose
Docker Compose runs the GraphQL Database Container (aka the Data Layer) – which will be directly connected with our GraphQL API Backend (aka the Business Layer containing all the logic, and filtering the access to the Data Layer).
$ cd database; docker-compose up -d; cd -
This was installed in the steps specified for 1. Node.JS. Prisma will generate some files to to the src/generated
directory based on your schema specifications inside the database/prisma.graphql
file.
$ prisma deploy
Make sure that the docker-compose containers are up and running the command $ docker-compose ps
.
$ npm start
The project should be running on https://localhost:3001 and you should see a GraphQL playground to test your queries.
query getInfo {
info
}
query allPlayers {
players {
id
name
}
}
(Note: See the GraphQL Playground Schema-tab or the source code's src/schema.graphql
file for available queries, mutations, inputs, subscriptions, etc. Run the signup query to retrieve an Authorization
token for the Headers section inside the playground, add eg.: { "Authorization" : "Bearer YOUR-AUTH-TOKEN-HERE" }
)
To directly access the data layer, run the following commands:
$ prisma playground
This fires up another playground for directly modifying the database. Though, in order to send queries – you'll need an authorization token. Run the following command to generate one:
$ prisma token
Add that token to the GraphQL Playground's Headers section, eg.:
{ "Authorization" : "Bearer YOUR-AUTH-TOKEN-HERE" }
Enjoy!
Planning to make this project run within its own Docker container or/and just deploy it to Heroku and Amazon Web Services (AWS). And do some API documentation.
TBD Copyright ©2018 – Roberth Hansson-Tornéus – R-H-T ([email protected])