A GraphQL api using Node.js, Apollo, Express, SQLite3, TypeGraphQl/TypeORM, Nodemailer and Jest with Typescript.
First, you need to clone this repository and install the project's dependencies.
Setup project(without Docker)
On your terminal, follow those steps:
- Clone those repository:
git clone https://github.com/nicknamedelta/nodeql.git
- Enter on project's folder:
cd nodeql
- Install dependencies with npm:
npm install
- Start Node.js server:
npm run dev:start
Setup project(with Docker)
On your terminal, follow those steps:
- Clone those repository:
git clone https://github.com/nicknamedelta/nodeql.git
- Enter on project's folder:
cd nodeql
- Generate a Docker image from a Dockerfile:
docker build -t nicknamedelta/nodeql .
- Start a new Docker container based on generated Docker image:
docker run --name nodeql -p 8080:8080 -d nicknamedelta/nodeql
After finish the project setup, access http://localhost:8080/graphql to see the GraphQl Playground in your project.
We're using Jest to make all Unit Tests in this project.
- Unit Tests using Jest(without Docker):
npm run test
- Unit Tests using Jest(with Docker):
docker exec -it <container_id> npm run test
mutation createCustomer {
createCustomer(
customer: {
name: "Delviniano Albernás"
email: "delv@alb.com"
cpf: "117.534.440-04"
dtBirth: "1992-02-12"
}
address: {
street: "Largo Prefeito Severino Procópio"
neighborhood: "Centro"
city: "Campina Grande"
state: "PB"
country: "BR"
number: "198"
cep: "58400-293"
}
) {
id
name
email
cpf
dtBirth
address {
street
neighborhood
city
state
country
number
cep
}
}
}
# allCustomers query
{
allCustomers {
id
name
email
cpf
dtBirth
address {
street
neighborhood
city
state
country
number
cep
}
}
}
mutation createProduct {
createProduct(
product: {
name: "Notebook Acer Nitro 5"
image: "image_path"
description: "Notebook Gamer Acer Nitro 5 Intel Core i5-10300H, NVIDIA GeForce GTX 1650, 8GB, SSD 512GB, 15.6 Full HD Ultrafino, Preto"
weight: 4
price: 4599
qttStock: 10
}
) {
id
name
qttStock
price
}
}
# allProducts query
{
allProducts {
id
name
price
qttStock
}
}
mutation {
createOrder(
order: { idCustomer: 1, installment: 2, listProducts: [{ id: 1, qtt: 2 }] }
) {
testEmailUrl
order {
id
dtOrder
installment
customer {
id
name
}
status
}
products {
id
name
qttStock
}
}
}
# allOrders query
{
allOrders {
id
status
installment
customer {
id
name
}
}
}