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;
- GraphQL with Absinthe on Phoenix - Mutation;
# clone the project
git clone [email protected]: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
Books:
{
books(limit: 2) {
id
name
position
verses(limit: 2) {
id
chapter
number
body
}
}
}
Book:
{
book(id: 1) {
id
name
position
verses(limit: 2) {
id
chapter
number
body
}
}
}
Create Book:
mutation {
createBook(name: "Book Name", position: 4) {
id
name
position
}
}
Create Book (Nested):
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:
mutation {
signup(email: "[email protected]", password: "password") {
token
user {
email
}
}
}
Signin:
mutation {
signin(email: "[email protected]", password: "password") {
token
user {
email
}
}
}