Skip to content

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

Notifications You must be signed in to change notification settings

raulpe7eira/food-diary

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FoodDiary API

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.

Previous installations

Database, we recommends install PostgreSQL with Docker. After that, sets connection configuration at:

  • config/dev.exs
  • config/test.exs

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

cd food-diary
mix deps.get
mix ecto.setup
mix test
mix test --cover
mix phx.server

How to use?

# 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

# 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
  }
}

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published