https://github.com/wbotelhos/graphql-with-absinthe-on-phoenix
GraphQL with Absinthe on Phoenix
https://github.com/wbotelhos/graphql-with-absinthe-on-phoenix
absinthe elixir graphql phoenix
Last synced: 6 months ago
JSON representation
GraphQL with Absinthe on Phoenix
- Host: GitHub
- URL: https://github.com/wbotelhos/graphql-with-absinthe-on-phoenix
- Owner: wbotelhos
- License: mit
- Created: 2021-07-31T15:25:37.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-07-25T02:19:55.000Z (about 2 years ago)
- Last Synced: 2025-03-30T10:51:12.017Z (7 months ago)
- Topics: absinthe, elixir, graphql, phoenix
- Language: Elixir
- Homepage: https://wbotelhos.com/graphql-with-absinthe-on-phoenix-query-and-dataloader
- Size: 86.9 KB
- Stars: 3
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# GraphQL with Absinthe on Phoenix
A guide teaching how to use Query, Dataloader, Mutation, Subscription and Authentication with GraphQL using Absinthe on Phoenix.
Read the article at:
- [GraphQL with Absinthe on Phoenix - Query and Dataloader](https://www.wbotelhos.com/graphql-with-absinthe-on-phoenix-query-and-dataloader);
- [GraphQL with Absinthe on Phoenix - Mutation](https://www.wbotelhos.com/graphql-with-absinthe-on-phoenix-mutation);## Setup
```sh
# clone the project
git clone git@github.com:wbotelhos/graphql-with-absinthe-on-phoenix.git# access the project
cd graphql-with-absinthe-on-phoenix# installs the dependencies
mix deps.get# creates the database
mix ecto.setup# run the server
mix phx.server# open the browser
open localhost:4000
```## GraphQL Queries
**Books**:
```gql
{
books(limit: 2) {
id
name
position
verses(limit: 2) {
id
chapter
number
body
}
}
}
```**Book**:
```gql
{
book(id: 1) {
id
name
position
verses(limit: 2) {
id
chapter
number
body
}
}
}```
**Create Book**:
```gql
mutation {
createBook(name: "Book Name", position: 4) {
id
name
position
}
}
```**Create Book (Nested)**:
```gql
mutation {
createBook(name: "Números", position: 4, verses: [{chapter: 1, number: 1, body: "No segundo ano..."}, {chapter: 1, number: 2, body: "Levantai o censo..."}]) {
id
name
position
verses {
body
chapter
id
number
}
}
}
```**Signup**:
```gql
mutation {
signup(email: "wbotelhos@gmail.com", password: "password") {
token
user {
}
}
}
```**Signin**:
```gql
mutation {
signin(email: "wbotelhos@gmail.com", password: "password") {
token
user {
}
}
}
```