To start your Phoenix server:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.create && mix ecto.migrate
- Seed database with
mix run priv/repo/seeds.exs
- Start Phoenix endpoint with
mix phx.server
To test:
- Navigate to
http://localhost:4000/graphiql
- Try a few queries & mutations, eg:
{
user(id: 1) {
id
username
email
}
}
{
"data": {
"user": {
"username": "User A",
"id": null,
"email": null
}
}
}
{
user(id: 1) {
id
username
email
}
}
{
"data": {
"user": {
"username": "User A",
"id": "5",
"email": "[email protected]"
}
}
}
mutation CreatePost {
createPost(title: "Post Title", body:"Body of the post.") {
body
title
}
}
{
"errors": [
{
"path": [
"createPost"
],
"message": "In field \"createPost\": Unauthorized",
"locations": [
{
"line": 3,
"column": 0
}
]
}
],
"data": {
"createPost": null
}
}
mutation CreatePost {
createPost(title: "Post Title", body:"Body of the post.") {
body
title
}
}
{
"data": {
"createPost": {
"title": "Post Title",
"body": "Body of the post."
}
}
}