Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/raulpe7eira/food-diary

ignite - module: elixir and graphql with absinthe from rocketseat by Rafael Camarda
https://github.com/raulpe7eira/food-diary

absinthe ecto elixir graphql ignite phoenix postgresql rocketseat

Last synced: about 2 months ago
JSON representation

ignite - module: elixir and graphql with absinthe from rocketseat by Rafael Camarda

Awesome Lists containing this project

README

        

# FoodDiary API

This repository is the code corresponding to the [Rocketseat - Ignite, Module: Elixir and GraphQL with Absinthe](https://app.rocketseat.com.br/node/elixir-e-graphql-com-absinthe-2022) lab by Rafael Camarda.

> The project simulates a Food Diary management API that allows to register users and meals 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 food-diary
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix phx.server
```

## How to use?

```bash
# 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
# retrieves user
query {
user(id: 1) {
email
name
}
}

# creates user
mutation {
createUser(input: {
email: "[email protected]",
name: "Fulano"
}) {
id
}
}

# creates meal
mutation {
createMeal(input: {
userId: 3,
description: "Pizza",
calories: 370.50,
category: FOOD
}) {
id
}
}

# listens new meal
subscription {
newMeal {
description
}
}
```