Giter Site home page Giter Site logo

rails-base-graphql-api's Introduction

API application template using Rails and GraphQL

Getting Started

Scripts

  • bin/setup - build Docker image and prepare DB
  • bin/server - to run server locally
  • bin/tests - runs RSpec tests
  • bin/quality - runs quality tools
  • bin/docker-sync - install docker-sync library to speed up performance on Mac OSX

Staging Environments

GraphQL query base path

https://rails-base-graphql-api.herokuapp.com/graphql

Apps and extensions for GraphQL

  1. Electron-based wrapper around GraphQL GraphiQL
  2. Chrome extension Altair GraphQL Client

How to start working with GraphQL:

  1. Choose your favorite tool for working with GraphQL
  2. Create a request for signup to get access and refresh tokens
# query
mutation SignUp($input: SignupInput!) {
  signup(input: $input) {
    me {
      id
      email
    }
    accessToken
    refreshToken
  }
}

# query variables
{
  "input": {
	"email": "[email protected]",
  	"password": "654321",
  	"firstName": "John",
  	"lastName": "Tolkien"
  }
}
  1. Use this token to send the following requests. Token sent to the "Authorization" in the header

Header example

Authorization: Bearer <token>

Bootstrap and run application

  1. Clone application repository
git clone git://github.com/fs/rails-base-graphql-api.git --origin rails-base-graphql-api [MY-NEW-PROJECT]

Create your new repo on GitHub and push master into it. Make sure master branch is tracking origin repo.

git remote add origin [email protected]:[MY-GITHUB-ACCOUNT]/[MY-NEW-PROJECT].git
git push -u origin master
  1. Run docker-sync setup script (optional, for Mac OSX users)
bin/docker-sync
  1. Run setup script
bin/setup
  1. Run test and quality suits to make sure all dependencies are satisfied and applications works correctly before making changes.
bin/tests
  1. Run application
bin/server

Useful commands

Run rails c console:

docker-compose exec app bin/rails c

Connect to postgres:

docker-compose exec app bin/rails db # password: "password"

View Rails logs:

docker-compose logs app

Github registry

We use Github Packages to store docker images. To use them you need to create Personal Access Token with the appropriate scopes(read_packages - to download images, write_packages - to upload). Authenticate to GitHub Packages with docker using docker login command:

cat ~/TOKEN.txt | docker login https://docker.pkg.github.com -u USERNAME --password-stdin

where TOKEN.txt - file with personal access token and USERNAME - your GitHub username

After that you can download docker image with the docker pull command:

docker pull docker.pkg.github.com/fs/rails-base-graphql-api/final:TAG_NAME

where TAG_NAME - name of the branch

To upload docker image use docker push command:

docker push docker.pkg.github.com/fs/rails-base-graphql-api/final:TAG_NAME

More details about image uploading you can find at GitHup Packages docs

Semaphore CI

To use GitHub Packages on Semaphore CI you can store Personal Access Token as the secret. After that add it to your .semaphore.yml config:

secrets:
  - name: github-docker-secrets

rails-base-graphql-api's People

Contributors

evgeniyesaulkov avatar azatzaynutdinov avatar arthurzaharov avatar dmitrybarskov avatar dependabot[bot] avatar mikhail-kilin avatar aleksandrseleznev avatar annaaleynik avatar zamanovarslan avatar arslanzamanov avatar kilinmikhail avatar maximovkonstantin 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.