Git Product home page Git Product logo

r-h-t / tf-graphql Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 3.16 MB

Table Football – GraphQL API Server, a supporting backend service for the Table Football React Web App front-end project (https://github.com/R-H-T/football)

Shell 0.34% JavaScript 99.66%
graphql api table football docker docker-compose es6 javascript apollo prisma mysql containers graphql-cli awesomeness js gql authorization tokens graphql-subscriptions node

tf-graphql's Introduction

Table Football – GraphQL API Server

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.


Index:


Getting Started

Setup (Step-by-Step)

Run all the terminal commands within the project root directory.

1. Node.JS 📦

This Project was developed using Node v8.11.3. (see https://nodejs.org for how to setup Node)

Upgrade npm to the latest version (Recommended):

$ sudo npm i -g npm@latest

Install The Global Dependencies:

$ sudo npm i -g prisma@ graphql-cli

Install Project Dependencies:

$ npm i

2. Docker & Docker Compose 🐳

Mac & Windows Users

See Docker for easy setup instructions for Mac & Windows users (https://www.docker.com/get-started).

Linux Users:

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).

Run the following command to start the server:

$ cd database; docker-compose up -d; cd -

3. Prisma🔺

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.

Deploy the existing database schema:

$ prisma deploy

Start The GraphQL API Server 🖲

Make sure that the docker-compose containers are up and running the command $ docker-compose ps.

Start The Server

$ npm start

The project should be running on http://localhost:3001 and you should see a GraphQL playground to test your queries.

Example GraphQL 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" })

Direct Access

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!


Future Plans

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.


License

TBD Copyright ©2018 – Roberth Hansson-Tornéus – R-H-T ([email protected])

tf-graphql's People

Contributors

r-h-t avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.