Git Product home page Git Product logo

graphql-demo's Introduction

Graphql Demo

Use koa + graphql + mongodb

首先本地安装mongodb,如果对mongodb不熟悉的同学,可以brew安装mongodb后,再安装mongodb-express可视化管理。

Install Mongodb

方式一

sudo chown -R {$whoami} /usr/local   // {$whoami} 为用户名文件夹名字
brew install mongodb    // 安装mongodb
mkdir -p /data/db       // 首次创建数据库文件夹,可能需要root权限
./mongod --dbpath=/data/db   // 指定数据库路径启动

方式二 下载安装包

http://www.runoob.com/mongodb/mongodb-linux-install.html

Quick Start

npm install

npm start

初始化 mongodb数据
访问 http://localhost:3000/initDB 会初始化3个Collection

avatar

访问 demo
http://localhost:3000

avatar

Graphql Request Test

访问http://localhost:3000/graphiql , 如下图
输入:

{ proLanguage {
  name
  desc
  uid
  key
} framework {
  name
  desc
} }

avatar

Variables

### params
query db($uid: String){
  proLanguage(uid: $uid, key: "jav") {
    _id
    name
    desc
    uid
    key
  }
  framework {
    _id
    name
    desc
  }
}


QUERY VARIABLES
{"uid": "1234"}

avatar

graphql-demo's People

Stargazers

 avatar  avatar

Watchers

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