https://github.com/raulpe7eira/twix
Crie APIs GraphQL com Elixir e Absinthe Course by Rafael Camarda
https://github.com/raulpe7eira/twix
absinthe api course elixir graphql learn phoenix udemy
Last synced: about 1 month ago
JSON representation
Crie APIs GraphQL com Elixir e Absinthe Course by Rafael Camarda
- Host: GitHub
- URL: https://github.com/raulpe7eira/twix
- Owner: raulpe7eira
- Created: 2024-01-16T00:49:09.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-18T23:25:24.000Z (about 1 year ago)
- Last Synced: 2025-02-12T07:23:59.282Z (3 months ago)
- Topics: absinthe, api, course, elixir, graphql, learn, phoenix, udemy
- Language: Elixir
- Homepage:
- Size: 58.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Twix
This code corresponds to the [Crie APIs GraphQL com Elixir e Absinthe Course](https://www.udemy.com/course/elixir-graphql) lab by [Rafael Camarda](https://cursos.rafaelcamarda.com/).
> The project simulates a twitter, where it's possible to register a user, add follower, send posts, and like posts.
## Compilation, tests and runs
```bash
$ cd twix
$ asdf install
$ mix compile
$ mix ecto.setup
$ mix test
$ iex -S mix phx.server
```## How to use?
```bash
# provide resources graphql
curl -X POST 'http://localhost:4000/api/graphql'# provide resources graphql w/ web development interface
curl -X POST 'http://localhost:4000/api/graphiql'# retrieve all users (
# rest endpoint consuming graphql
# )
curl -X GET 'http://localhost:4000/api/users'
```### Resources GraphQL
```bash
# retrieve user (
# the posts is paginated
# )
query{
user(id: 1) {
nickname
age
followers{
follower{
nickname
}
}
followings{
following{
nickname
}
}
posts(page: 1, perPage: 1){
id
text
likes
}
}
}# retrieve all users
query{
users{
id
nickname
age
}
}# create user
mutation{
createUser(input: {nickname: "Raul", email: "[email protected]", age: 42}){
id
nickname
age
}
}# update user
mutation{
updateUser(input: {id: 1, age: 43}){
id
nickname
age
}
}# add follower
mutation{
addFollower(input: {userId: 1, followerId: 2}){
followerId
followingId
}
}# -----------------------------------------------------------------------------
# create post
mutation{
createPost(input: {userId: 1, text: "Olá mundo"}){
id
text
likes
}
}# like a post
mutation{
addLikeToPost(id: 1){
id
text
likes
}
}
```