基于typescript 强大的 nestjs 框架试用

nestjs 一个nodejs 的graphql 框架

安装

npm i -g @nestjs/cli

初始化项目

nest new dalong

运行demo

使用yarn

yarn start

添加graphql支持

参考官方demo sample/12-graphql-apollo

  • 运行
yarn && yarn start
  • 效果
  • 操作
    添加

    查询

源码结构说明

代码比较简单,写过angular 的基本都可以看懂,主要是依赖注入,服务定义,以及graphql schema 定义,graphql resovler 编写
同时代码包含了一个subscription 的功能(基于ws 包, graphql 的实现基于apollo 以及express 代码还是很清晰的。 

参考资料

https://docs.nestjs.com/
https://github.com/nestjs/nest/tree/master/sample

原文地址:https://www.cnblogs.com/rongfengliang/p/9392323.html