- Setup Project
- Testing with GraphiQL
- Example Queries
- Single Post
- Collection of Posts
- Example Mutations
- Create Post
- Update Post
- Delete Post
bundle
rails db:setup
rails s
brew install --cask graphiql
{
post(id: "12d08a32-1cee-4681-84d0-4ef45a51203b") {
id
title
body
}
}
{
posts {
id
title
body
}
}
mutation {
createPost(title:"New Post", body: "Another fantastic Post") {
id
title
body
}
}
mutation createPost($title:String!, $body:String!) {
createPost(title: $title, body: $body) {
id
title
body
}
}
{
"title": "New Post",
"body": "Another fantastic Post"
}
mutation createPost($post:PostInputType!) {
createPost(post: $post) {
id
title
body
}
}
{
"post": {
"title": "New Post",
"body": "Another fantastic Post"
}
}
mutation {
updatePost(id: "12d08a32-1cee-4681-84d0-4ef45a51203b", title:"Updated Post", body: "Updated Body") {
id
title
body
}
}
mutation updatePost($title:String!, $body:String!) {
updatePost(title: $title, body: $body) {
id
title
body
}
}
{
"id": "12d08a32-1cee-4681-84d0-4ef45a51203b",
"title": "Updated Post",
"body": "Updated Body"
}
mutation updatePost($post:PostInputType!) {
updatePost(post: $post) {
id
title
body
}
}
{
"post": {
"id": "12d08a32-1cee-4681-84d0-4ef45a51203b",
"title": "Updated Post",
"body": "Updated Body"
}
}
mutation {
deletePost(id: "12d08a32-1cee-4681-84d0-4ef45a51203b") {
id
}
}
mutation deletePost($id:ID!) {
deletePost(id: $id) {
id
}
}
{
"id": "12d08a32-1cee-4681-84d0-4ef45a51203b",
}
mutation deletePost($post:PostInputType!) {
deletePost(post: $post) {
id
}
}
{
"post": {
"id": "12d08a32-1cee-4681-84d0-4ef45a51203b",
}
}