Giter Club home page Giter Club logo

graphqlapi's Introduction

Setup

Run the commands below.

$ git clone https://github.com/K-Sato1995/GraphqlApi.git
$ bundle install
$ rake db:migrate

Queries and Mutations

Run rails s and send following queries and mutations.

Get posts

{
  posts {
    id
    title
    description
    comments
  }
}

Search Posts

This is just an example. Check out Ransack's README for more search Matchers.

{
  posts(q: { status_eq: "PUBLISHED" }) {
    id
    title
    description
    status
    comments {
      id
    }
  }
}

Get a post

{
  post(id: 1) {
    id
    title
    description
    comments {
      id
      content
    }
  }
}

Creating a post

mutation {
  createPost(input: { title: "title1", description: "description1" }) {
    post {
      id
      title
      description
    }
  }
}

Updating a post

mutation {
  updatePost(input: { id: 1, title: "Updated", description: "UPdated" }) {
    post {
      id
      title
      description
    }
  }
}

Deleting a post

mutation {
  deletePost(input: { id: 1 }) {
    post {
      id
      title
      description
    }
  }
}

Creating a comment

mutation {
  createComment(input: { postId: 3, content: "NEW COMMENT" }) {
    comment {
      id
      content
      post {
        id
        title
        comments {
          id
          content
        }
      }
    }
  }
}

Creating a User

mutation {
  createUser(
    input: {
      name: "title1"
      authProvider: { email: { email: "[email protected]", password: "passsssord" } }
    }
  ) {
    user {
      id
      name
      email
    }
  }
}

Signing in a User

mutation {
  signinUser(
    input: { email: { email: "[email protected]", password: "passsssord" } }
  ) {
    token
  }
}

Query for getting all the related information

{
  posts {
    id
    title
    description
    status
    mediaItem {
      __typename
      ... on AudioClip {
        id
        duration
      }
      ... on VideoClip {
        id
        previewUrl
        resolution
      }
    }
    comments {
      id
      content
    }
  }
}

Front End

The front end of this api buit in TypeScript.

graphqlapi's People

Contributors

k-sato1995 avatar k-sato0130 avatar dependabot[bot] avatar

Stargazers

Roman avatar Miral Achmed avatar  avatar Mathew P. Jones avatar  avatar Cássio Jandir Pagnoncelli avatar Parwat Kunwar avatar  avatar Lo Axhamre avatar

Watchers

James Cloos avatar  avatar

graphqlapi's Issues

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.