Giter VIP home page Giter VIP logo

hacker-news-graphql's Introduction

Hackernew Clone using GraphQL

Overview

Straightforward implementation of a Hackernews clone using Ruby on Rails and GraphQL from https://www.howtographql.com/graphql-ruby/0-introduction/. Features include creating accounts, creating and searching for links, as well as up voting links.

Having gained some exposure to REST APIs, I have wanted to start digging into and learning about GraphQL, given increased popularity and growing community. This marks one of the first of many future GraphQL projects!

Installation

To install and test locally yourself:

  1. Clone this repo
  2. Install the required gems by running
$ bundle install
  1. Start the server
$ rails server
  1. Open a browser and open the in-browser GraphQL IDE at http://localhost:3000/graphiql

Sample GraphQL Queries

Once in the GraphQL IDE, there are a number of different queries and mutations which can be run to test any of the functionality. Some examples...

List first 10 links, containing "example":

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

Create new user:

mutation {
  createUser(
    name: "Radoslav Stankov",
    authProvider: {
      credentials: { email: "[email protected]", password: "123456" }
    }
  ) {
    id
    email
    name
  }
}

Create new user token:

mutation {
  signinUser(credentials: {email: "[email protected]", password: "123456"}) {
    token
    user {
      id
      email
      name
    }
  }
}

Create new link:

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

Create new vote:

mutation {
  createVote(linkId:"TGluay0yMQ==") {
    user {
      id
      name
    }
    link {
      id
      url
      description
    }
  }
}

hacker-news-graphql's People

Contributors

ayrt-n avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.