在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(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 exampleThis is a simple experimental example of how to match graphql-js and MySQL for the implementation of a GraphQL API.
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 operationsShow 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 baconmutation {
addBacon(type: "truffy", price: 99) {
id,
type
price
}
} Updates a baconmutation {
updateBacon(id: 1, type: "musky", price: 1) {
id,
type
price
}
} LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论