Git Product home page Git Product logo

graphql-demo's Introduction

GraphQL Demo

A simple app to demonstrate GraphQL ๐Ÿ˜Ž

How to run ?

Make sure you have node version > 6. If you have nvm installed on your machine type nvm use in the the root project directory.

  1. git clone https://github.com/ghoshabhi/graphql-demo.git

  2. cd graphql-demo/users

  3. Install dependencies:

    npm install or

    yarn

  4. To run the mock json-server run the following command:

    npm run json:server

  5. To run the GraphQL server:

    npm run dev

Sample Query:

  1. Get All Users:
query {
  getAllUsers {
    id
    firstName
    age
    company {
      name
      description
    }
  }
}
  1. Fetch one User:
query {
  getUser(id: "1") {
    firstName,
    age
  }
}
  1. Fetch All Companies and its employees/users:
query {
  getAllCompanies {
    name
    description
    users{
      firstName,
      age
    }
  }
}

Sample Mutations

  1. Add User:
mutation {
  addUser(firstName: "John Doe", age: 24) {
    id
    firstName
    age
  }
}
  1. Update User:
mutation updateInfo ($id: String!, $name: String, $age: Int){
  updateUser(id: $id, firstName: $name, age: $age) {
    id
    firstName
    age
  }
}

And in Query Variables add the following:

{
  "id": "1",
  "name": "Updated Name"
  "age": 23
}

graphql-demo's People

Contributors

ghoshabhi avatar

Watchers

James Cloos avatar  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.