Git Product home page Git Product logo

node-graphql-example's Introduction

NODE API GRAPHQL

This is a simple API using Node.js, Apollo Server and GraphQL.

Getting Started

Prerequisites

  • Node.js
  • Yarn

Installing

  1. Install the dependencies
yarn
  1. Run the server
yarn start
  1. Access the GraphQL Playground
http://localhost:4000/

Querying

Its possible to query the users, todos and todo by id.
Change the query to get the data you want.

query GetUsers {
  users {
    name,
    todos {
      text
    }
  }
}

query GetTodos {
  todos {
    id
    text
    completed
    user {
      name,
    }
  }
}

query GetTodoById {
  todoById(id: 1) {
    id
    text
    completed
    user {
      id
      name
    }
  }
}

query GetCompletedTodo {
  todoCompleted(completed: true) {
    text
    user {
      name
    }
  }
}

Mutations

Its possible to create, update, delete and set a todo as completed.
Change the mutation to get the data you want.

mutation CreateTodo {
  addTodo(text: "Wash car", completed: false, userId: 1) {
    text
  }
}

mutation SetTodoCompleted {
  setTodoCompleted(id: 1, completed: true) {
    text
    completed
  }
}

mutation UpdateTodo {
  updateTodo(id: 1, text: "Changed Todo") {
    text
  }
}

mutation DeleteTodo {
  deleteTodo(id: 1) {
    id
  }
}

node-graphql-example's People

Contributors

galloaleonardo 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.