@yunflyjs/yunfly-plugin-apollo
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@yunflyjs/yunfly-plugin-apollo

yunfly apollo plugin.

Usage

  1. install
yarn add @yunflyjs/yunfly-plugin-apollo
  1. declare plugins in config/config.plugin.ts
/**
 * yunfly plugin
 */
const plugins: {[key:string]: string}[] = [
  {
    name: 'apollo',
    package: '@yunflyjs/yunfly-plugin-apollo',
    lifeHook: 'beforeStart'
  }
];
// 
export default plugins;
  1. enable plugins in config/config.default.ts
config.apollo = {
  enable: true,
  // serviceName: 'example-apollo-service',
  // serviceUrl: 'http://xxx.com',
  // secret: 'xxxxxx',
  // namespace: 'application'
}

config options

interface

export interface ApolloConfig {
  enable?: boolean;
  secret?: string;
  serviceUrl?: string;
  namespace?: string;
  serviceName?: string;
}

description

field type required default notes
enable boolean yes false enable the plugin
secret string no process.env.APOLLO_ACCESSKEY_SECRET apollo secret
serviceUrl string no process.env.APOLLO_META_SERVER_URL apollo host url
namespace string no application apollo config namespace
serviceName string no packageJson.name

api

  • getApolloConfig

api usage

import { getApolloConfig } from '@yunflyjs/yunfly-plugin-apollo';

console.log('getApolloConfig',getApolloConfig);
  • get apollo config in controller
import { Controller, Get } from '@yunflyjs/yunfly';
import { getApolloConfig } from '@yunflyjs/yunfly-plugin-apollo';
 
@Controller()
export class ExampleController {
  @Get('/users')
  getApolloConfig() {
    return getApolloConfig();
  }
}

env

process.env.APOLLO_META_SERVER_URL

apollo url host address, need to start with http:// or https://.

  • priority

config.apollo.serviceUrl > process.env.APOLLO_META_SERVER_URL

process.env.APOLLO_ACCESSKEY_SECRET

if the apollo management side has enabled the secret key, this parameter needs to be passed.

  • priority

config.apollo.secret > process.env.APOLLO_ACCESSKEY_SECRET

其他说明

  1. apollo hot update
  2. failed to retry 5 times

Readme

Keywords

Package Sidebar

Install

npm i @yunflyjs/yunfly-plugin-apollo

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

20.4 kB

Total Files

20

Last publish

Collaborators

  • wangweianger