IONIC2 Apollo Graphql Eror:找不到名字' AsyncIterator'

时间:2017-08-22 06:49:24

标签: ionic2 graphql apollo-client

我正在使用graphql服务开始开发离子应用程序但是我在节点模块中遇到了一些问题,我该如何解决这个问题?

[14:32:44]  typescript: D:/ionic/node_modules/@types/graphql/subscription/subscribe.d.ts, line: 17 
            Cannot find name 'AsyncIterator'.

      L16:      subscribeFieldResolver?: GraphQLFieldResolver<any, any>
      L17:  ): AsyncIterator<ExecutionResult>;

[14:32:44]  typescript: D:/ionic/node_modules/@types/graphql/subscription/subscribe.d.ts, line: 29 
            Cannot find name 'AsyncIterable'.

      L28:      fieldResolver?: GraphQLFieldResolver<any, any>
      L29:  ): AsyncIterable<any>;

这是我的package.json

 {
      "name": "Test",
      "author": "test,
      "homepage": "http://test.com",
      "private": true,
      "scripts": {
        "clean": "ionic-app-scripts clean",
        "build": "ionic-app-scripts build",
        "ionic:build": "ionic-app-scripts build",
        "ionic:serve": "ionic-app-scripts serve"
      },
      "dependencies": {
        "@angular/common": "2.4.8",
        "@angular/compiler": "2.4.8",
        "@angular/compiler-cli": "2.4.8",
        "@angular/core": "2.4.8",
        "@angular/forms": "2.4.8",
        "@angular/http": "2.4.8",
        "@angular/platform-browser": "2.4.8",
        "@angular/platform-browser-dynamic": "2.4.8",
        "@angular/platform-server": "2.4.8",
        "@ionic/storage": "^1.1.9",
        "angular2-jwt": "^0.1.28",
        "apollo-angular": "^0.13.0",
        "apollo-client": "^1.9.1",
        "graphql-tag": "^2.4.2",
        "ionic-angular": "^2.1.0",
        "ionic-native": "2.5.1",
        "ionicons": "3.0.0",
        "rxjs": "5.2.0",
        "sw-toolbox": "3.6.0",
        "zone.js": "0.7.7"
      },
      "devDependencies": {
        "@ionic/app-scripts": "^2.1.4",
        "typescript": "^2.3.4"
      },
      "cordovaPlugins": [
        "ionic-plugin-keyboard",
        "cordova-plugin-whitelist",
        "cordova-plugin-console",
        "cordova-plugin-statusbar",
        "cordova-plugin-device",
        "cordova-plugin-splashscreen",
        "cordova-plugin-camera",
        "cordova-plugin-app-version"
      ],
      "cordovaPlatforms": [],
      "description": "TEST"
    }

2 个答案:

答案 0 :(得分:4)

&#34; esnext.asynciterable&#34; lib添加到文件 tsconfig.json

"compilerOptions": {
  "lib": [
     . . .
     "esnext.asynciterable"
     . . .
   ],
. . .

答案 1 :(得分:3)

从错误消息中看起来您安装了graphql-js的类型声明。 npm链接是here

输入声明链接here

package.json中似乎没有类型声明和库。

如果这是您打算使用的库,则需要使用npm install --save graphql 选项进行安装,如下所示:

save-dev

带有npm install --save-dev @types/graphql 选项的类型可添加到dev依赖项。

{{1}}