egg-data-model-plugin

1.0.3 • Public • Published

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

Package Sidebar

Install

npm i egg-data-model-plugin

Weekly Downloads

4

Version

1.0.3

License

MIT

Unpacked Size

11.8 kB

Total Files

8

Last publish

Collaborators

  • userya