Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加 egg-socket.io 和 egg-graphql 支持 #60

Open
droplet-js opened this issue Mar 19, 2020 · 4 comments
Open

添加 egg-socket.io 和 egg-graphql 支持 #60

droplet-js opened this issue Mar 19, 2020 · 4 comments

Comments

@droplet-js
Copy link

添加 egg-socket.io 和 egg-graphql 支持,不然手写太蛋疼了

@whxaxes
Copy link
Member

whxaxes commented Mar 19, 2020

https://github.com/whxaxes/egg-ts-helper/blob/master/README.zh-CN.md#generator 可以尝试用 generator 配置自动生成 d.ts

@droplet-js
Copy link
Author

droplet-js commented Mar 19, 2020

egg-socket.io 比较简单,解决了
egg-graphql 不好解决,我的想法是类似controller做法
将 ./app/graphql/user/connector.ts
输出 ./typings/app/connector/index.d.ts

declare module 'egg' {
  interface Context {
    connector: IConnector;
  }

  interface IConnector {
    user: ExportUser
  }
}

请帮忙校正错误,谢谢 ...
./tshelper.js

module.exports = {
  watchDirs: {
    graphql_connector: {
      directory: 'app/graphql',
      // pattern: '**/*.(ts|js)',
      generator: 'auto',
      interface: 'IConnector',
      declareTo: 'Context.connector',
    },
    socket_io_controller: {
      directory: 'app/io/controller',
      generator: 'class',
      interface: 'CustomController',
    },
  },
};

@whxaxes
Copy link
Member

whxaxes commented Mar 20, 2020

@v7lin 你可以试一下。。。。我这边没有用过 graphql 。。。不太好验证

@wbget
Copy link

wbget commented Mar 27, 2020

socket.io有效,另一个也没用过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants