- Ruby 2.5.3
- Rails 5.2.2
- Written with PostgreSQL in mind, edits to Gemfile and Database.yml required for other SQL Services
- Bash terminal (Curl or Git Bash, etc)
-
Download this repository
-
Edit Database.yml and Gemfile to work with your SQL server
-
Run migrate to create tables in your database,
$ rb db:migrate
-
You can populate the database with:
-
JSON POST requests
-
Run:
$ rb db:seed
, to populate with random items
-
-
A software, example: Postman
-
Using a bash terminal
-
Using
localhost:3000/graphiql
, this also conatins a basic documentation on each query and mutation type defined.
- Create a new product:
mutation {
createProduct(title: <String>, price: <Float, inventory_count: <Integer>) {
id
title
price
inventory_count
}
}
- Search Filters:
query{
allProducts(filter: {in_stock: <Boolean>}) {
title
price
inventory_count
}
}
query{
allProducts(filter: {title_contains: <String>}) {
title
price
inventory_count
}
}
- Create User:
mutation {
createUser(name: <String>, authProvider: {email: {email: <String>, password: <String>}}) {
id
name
email
}
}
- Sign in:
mutation {
signinUser(email: {email: <String>, password: <String>}) {
token
user {
id
}
}
}
-
Add "Shopping Cart"
-
Add inventory_count update function
-
Faker Gem was used to create the random seed of objects to populate the database
-
bcrypt gem was used to authenticate and encrypt login details
-
A geat tutorial on Rails 5 REST API