nodejs graphql
2022年1月6日安装 graphql
1 |
npm install graphql |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
var { graphql, buildSchema } = require('graphql'); var schema = buildSchema(` type Query { hello: String } `); var root = {hello: () => 'Hello world!'}; /** * 注册进入 * schema : 模式 * var : 要查询那个模式 hello * var : 查询到这个模式调用的方法 */ graphql(schema, '{ hello }', root).then((response) => { console.log(response); }); |