• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

YuLeven/nodejs-graphql-mysql-example: An example Express based app implementing ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

YuLeven/nodejs-graphql-mysql-example

开源软件地址(OpenSource Url):

https://github.com/YuLeven/nodejs-graphql-mysql-example

开源编程语言(OpenSource Language):

JavaScript 100.0%

开源软件介绍(OpenSource Introduction):

NodeJS graphQL MySQL example

This is a simple experimental example of how to match graphql-js and MySQL for the implementation of a GraphQL API.

  • This project requires a version of NodeJS with support for async-await

Getting Started

# clone the project
git clone [email protected]:YuLeven/nodejs-graphql-mysql-example.git
cd nodejs-graphql-mysql-example

# Install dependencies
npm install

# Create Schema in MySQLfor Linux/Unix/MacOS
mysql -h <host> -P 3306  -u <user>  -p  < ./sql/exapp.sql

# Run the server
PORT=8080 MYSQL_DB_USER=root MYSQL_DB_NAME=exapp MYSQL_DB_PASSWORD=secret MYSQL_DB_ADDRESS=localhost MYSQL_DB_POOL_SIZE=10 npm start

# Access GraphQLi
http://localhost:8080/graphql

Please remember to export the example SQL schema located in ./sql/exapp.sql

Example operations

Show all bacons

{
  bacons {
    id,
    type,
    price
  }
}

Filter bacons by price

{
  bacons(price: 25) {
    id,
    type,
    price
  }
}

Gets a bacon by its ID

{
  bacon(id: 1) {
    id,
    type,
    price
  }
}

Adds a new bacon

mutation {
  addBacon(type: "truffy", price: 99) {
    id,
    type
    price
  }
}

Updates a bacon

mutation {
  updateBacon(id: 1, type: "musky", price: 1) {
    id,
    type
    price
  }
}

License

MIT




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap