1.0.3 • Published 5 years ago

egg-data-model-plugin v1.0.3

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

egg-data-model-plugin

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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.

License

MIT