Skip to content

GraphQL Ruby Blog example for me βœŒοΈπŸ‘¨πŸ»β€πŸ’»

License

Notifications You must be signed in to change notification settings

CamiloQuezadaDev/graphql-ruby-blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

graphql-ruby Graphql Ruby Blog

Β 

Table of contents:

Β 

This Proyect has the following features:

  • authentication system
  • users can create, read, update and delete blogs
  • users can comment the blog of other user
  • users can clap the blog of other user
  • users can save the blog of other user to favorites

Β 

Installation

Install dependencies:

bundle install

rails db:setup

Starting the server:

rails server

Opening the application:

open http://localhost:3000/

or

http://localhost:3000/graphiql

Β 

Interesting Files:

Root files

Record types

Mutations

Β 

Sample GraphQL Queries

Sign Up:

mutation {
  signUp(input: { name: "Leonardo da Vinci", credentials: { email: "leonardo@example.com", password: "leonardo123" } } ) {
    user {
      id 
      email 
      name
    }
    success
    errors
  }
}

Create new user token:

mutation {
  signIn(input: { credentials: { email: "leonardo@example.com", password: "leonardo123" } }) {
    user {
      id 
      email 
      name
    }
  success
  token
  errors
  }
}

Create post:

mutation {
  createPost(input: { title:"How to create a GraphQL Blog with Rails", body:"Vitae eaque dolor. Et amet laudantium. Molestiae velit quos." }) {
    post {
      id
      title
      content
      postedAt
      updatedAt 
      postedBy {
        name
      }
    }
  success
  errors
  }
}

Update post:

mutation {
  updatePost(input: { id:"1", title:"How to create a React App", body:"Vitae eaque dolor. Et amet laudantium. Molestiae velit quos."}) {
    post {
      id
      title
      content
      postedAt
      updatedAt 
      postedBy {
        name
      }
    }
  updated
  errors
  }
}

Destroy post:

mutation {
  destroyPost(input: { id:"1"}) {
    post {
      id
      title
      content
      postedAt
      updatedAt 
      postedBy {
        name
      }
    }
  deleted
  errors
  }
}

Add Comment:

mutation {
  addComment(input: { postId:"1", content:"I love your Post"} ) {
  comment {
    id 
    content
    commentedBy {
      id
      name
    }
  }
    errors
    success
  }
}

Add Clap

mutation {
  addClap(input: {postId:"3"}){
    clap {
      clappedBy {
        name
      }
    }
    success
    errors
  }
}

Add Favorite

mutation {
  addFavorite(input: {postId:"3"}){
    favorite {
      title
    }
    success
    errors
  }
}

Delete Favorite

mutation {
  deleteFavorite(input: {postId:"3"}){
    favorite {
      title
    }
    errors
    deleted
  }
}

Β 

Inspiration

This sample app is based on graphql-ruby tutorial from howtographql

Β 

Lookin' at the source code huh? Be sure to drop me a line! I'd love to chat, whether it's about code, design, sports, coffee, books, or anything in between. πŸ‘¨πŸ»β€πŸ’»β˜•οΈ

About

GraphQL Ruby Blog example for me βœŒοΈπŸ‘¨πŸ»β€πŸ’»

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published