构建基于GraphQL和Apollo的Angular待办事项应用
1. 访问数组元素
在代码中,若要使填充的数组项更具实用性,就需要能够在代码的其他部分访问这些元素。通过添加一个 Items 属性,就能轻松实现这一目的:
get Items(): TodoItem[] {
return this.items;
}
2. 创建GraphQL模式
在数据库代码就绪后,接下来要着手编写GraphQL服务器。为简化代码编写过程,我们选择使用 type-graphql 。首先,通过以下命令进行安装:
npm install type-graphql @types/graphql reflect-metadata --save
同时,需要将 tsconfig 文件配置如下:
{
"compileOnSave": false,
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"lib": ["es2016", "esnext.asynciterable", "dom"],
"outDir": "./dist",
"noImplicitAny": true,
"esMod
超级会员免费看
订阅专栏 解锁全文
12

被折叠的 条评论
为什么被折叠?



