git clone [email protected]:sonyged/GraphQL-Playground.git
cd BookGQL
-
For docker setup
script/docker/setup.sh script/docker/start.sh
-
For non docker setup
bundle install rails db:create db:migrate db:fake rails s
sign in at http://localhost:3000/users/sign_in
email: [email protected]
password: test123456
then access to GraphiQL at http://localhost:3000/graphiql
- Query
query showBook($id: ID!) {
book(id: $id) {
id
title
content
user {
id
email
}
}
}
- Variable
{
"id": 1
}
- Query
query indexBooks {
books {
id
title
content
user {
id
email
}
}
}
- mutation
mutation CreateBook($title: String!, $content: String!) {
CreateBook(title: $title, content: $content) {
book {
id
content
title
user {
id
email
}
}
code
errors
}
}
- Variable
{
"title": "Book title",
"content": "Book content"
}
- mutation
- You can update only book that you create
mutation UpdateBook($id: ID!, $title: String!, $content: String!) {
UpdateBook(id: $id, title: $title, content: $content) {
book {
id
content
title
user {
id
email
}
}
code
errors
}
}
- Variable
{
"id": 31,
"title": "updated book title",
"content": "updated book content"
}
- showBook: user required
- access book created_at: admin required
- view book's author: admin required
- indexBook: user required
- createBook: user required
- updateBook: owner required