This repository is the code corresponding to the Rocketseat - Ignite, Module: Elixir and GraphQL with Absinthe lab by Rafael Camarda.
The project simulates a Food Diary management API that allows to register users and meals with GraphQL.
Database, we recommends install PostgreSQL with Docker. After that, sets connection configuration at:
config/dev.exs
config/test.exs
cd food-diary
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix phx.server
# 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'
# retrieves user
query {
user(id: 1) {
email
name
}
}
# creates user
mutation {
createUser(input: {
email: "fulano@mail.com",
name: "Fulano"
}) {
id
}
}
# creates meal
mutation {
createMeal(input: {
userId: 3,
description: "Pizza",
calories: 370.50,
category: FOOD
}) {
id
}
}
# listens new meal
subscription {
newMeal {
description
}
}