Skip to content
GraphQL Ruby example for How To GraphQL
Branch: master
Clone or download
Latest commit 73d73b9 Jun 2, 2019

README.md

graphql-ruby

Installation

Install dependencies:

bundle install

rails db:create
rails db:migrate
rails db:seed

Starting the server:

rails server

Opening the application:

open http://localhost:3000/

Interesting Files:

Sample GraphQL Queries

List first 10 links, containing "example":

{
  allLinks(first: 10, filter: {descriptionContains: "example"}) {
    id
    url
    description
    createdAt
    postedBy {
      id
      name
    }
  }
}

Creates new user:

mutation {
  createUser(
    name: "Radoslav Stankov",
    authProvider: {
      email: { email: "rado@example.com", password: "123456" }
    }
  ) {
    id
    email
    name
  }
}

Creates new user token:

mutation {
  signinUser(email: {email: "rado@example.com", password: "123456"}) {
    token
    user {
      id
      email
      name
    }
  }
}

Creates new link:

mutation {
  createLink(url:"http://example.com", description:"Example") {
    id
    url
    description
    postedBy {
      id
      name
    }
  }
}

Creates new vote:

mutation {
  createVote(linkId:"TGluay0yMQ==") {
    user {
      id
      name
    }
    link {
      id
      url
      description
    }
  }
}
You can’t perform that action at this time.