Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/raulpe7eira/wabanex

nlw#6 - trilha elixir from rocketseat by Rafael Camarda
https://github.com/raulpe7eira/wabanex

absinthe crudry ecto elixir graphql nlw nlw-6-elixir phoenix postgresql rocketseat

Last synced: about 2 months ago
JSON representation

nlw#6 - trilha elixir from rocketseat by Rafael Camarda

Awesome Lists containing this project

README

        

# Wabanex API

This repository is the code corresponding to the [nlw#6 - trilha elixir](https://nextlevelweek.com/) lab by Rafael Camarda.

> The project simulates a Gym Training management API that allows to register trainings and exercises with GraphQL.

## Previous installations

**Database**, we recommends install [PostgreSQL](https://www.postgresql.org/) with [Docker](https://hub.docker.com/_/postgres). After that, sets connection configuration at:

- `config/dev.exs`
- `config/test.exs`

## Gets dependencies, setups database, tests, coverages, reports and starts application

```bash
cd wabanex
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix phx.server
```

## How to use?

```bash
# calculate imc (
# replaces curly braces:
# {filename} : file name (e.g.: students.csv)
# )
curl -X GET 'http://localhost:4000/api?filename={filename}'

# provides resources graphql
curl -X POST 'http://localhost:4000/api/graphql'

# provides resources graphql with web development interface
curl -X POST 'http://localhost:4000/api/graphiql'
```

### Resources GraphQL

```bash
# creates user
mutation {
createUser(input: {
name: "beltrano",
email: "[email protected]",
password: "123"
}) {
id
}
}

# creates training
mutation {
createTraining(input: {
endDate: "2021-12-12",
startDate: "2021-12-11",
userId: "b4156e52-79d7-4625-a411-b3535f376d49",
exercises: [
{
name: "Triceps",
youtubeVideoUrl: "https://youtuba.com/fulano",
repetitions: "3x15",
protocolDescription: "drop-set"
},
{
name: "Biceps",
youtubeVideoUrl: "https://youtuba.com/fulano",
repetitions: "4x15",
protocolDescription: "drop-set"
}
]
}) {
id
}
}

# retrieves user
{
getUser(id: "b4156e52-79d7-4625-a411-b3535f376d49") {
id
name
email
trainings {
id
startDate
endDate
exercises {
id
name
youtubeVideoUrl
repetitions
protocolDescription
}
}
}
}
```