egg-data-model-plugin
v1.0.3
Published
[![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][codecov-image]][codecov-url] [![David deps][david-image]][david-url] [![Known Vulnerabilities][snyk-image]][snyk-url] [![npm download][download-image]][down
Downloads
5
Readme
egg-data-model-plugin
Install
$ npm i egg-data-model-plugin --save
Usage
// {app_root}/config/plugin.js
exports.dataModelPlugin = {
enable: true,
package: 'egg-data-model-plugin',
};
Configuration
// {app_root}/config/config.default.js
exports.middleware = ['dataModel'];
exports.dataModelPlugin = {
schema: {
request: {
url: 'http://localhost:5000/g/schema/dev-ops',
},
},
endpoints: {
url: 'http://localhost:5000/g/dev-ops',
options: {},
},
router:'graphql',
};
Example
- in code example
//app/controller/test.js
async index() {
const {ctx} = this;
const data = ctx.gql`
query {
dev_access_page {
objects {
_all_field
}
}
}
`
const resp = await ctx.app.dataModel.query(data)
console.log(resp)
ctx.body = resp;
}
Questions & Suggestions
Please open an issue here.