Simple API made with Elixir, GraphQL and Absinthe to achieve a Twitter-like experience.
Before you begin, ensure you have met the following requirements:
- Elixir 1.10+ installed
- Erlang/OTP 22+ installed
- PostgreSQL installed and running
Follow these steps to get your development environment set up:
-
Clone the Repository
git clone https://github.com/yantavares/x-api cd x-api/api
-
Install Elixir Dependencies
Run the following command to install the Elixir dependencies specified in
mix.exs
:mix deps.get
-
Create and Migrate Your Database
Make sure your PostgreSQL service is running.
From
dev.exs
:config :api, Api.Repo, username: "postgres", password: "postgres", hostname: "localhost", database: "api_dev",
Then, create and migrate your database:
mix ecto.setup
This command is a shortcut for
mix ecto.create
,mix ecto.migrate
, andmix run priv/repo/seeds.exs
to seed the database. -
Start the Phoenix Server
You can start your Phoenix app in one of two ways:
-
To start the server normally:
mix phx.server
-
To start within an interactive Elixir shell (IEx):
iex -S mix phx.server
Now you can visit
localhost:4000
from your browser to see the running application. -
To explore the GraphQL API and documentation, visit http://localhost:4000/api/graphiql
in your web browser. This interface allows you to execute queries and mutations against your API in real-time.
To see query examples, please read the README
file inside api
folder.
To run the tests, use the following command:
mix test
- Phoenix Framework: Official website
- Absinthe GraphQL: Documentation
- Elixir Language: Official website
- Elixir Forum: Phoenix Forum